home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / DEFENDER.ZIP / DEFENDER.BAS < prev    next >
BASIC Source File  |  1996-02-01  |  118KB  |  4,222 lines

  1.  ' Defender.bas
  2.  ' Tim Truman
  3.  ' 4/28/95
  4.  ' Copyright (c) 1995,1996 Tim Truman
  5.  ' Distribute this program freely.
  6.  '
  7.  '
  8.  DEFINT A-Z
  9.  
  10.  DECLARE SUB printme ()
  11.  
  12.  DECLARE SUB setfxmode ()
  13.  DECLARE SUB herosprite ()               '  draw and initalize main sprite
  14.  DECLARE SUB starfield ()
  15.  DECLARE SUB processgpi ()               '  process game play input
  16.  
  17.  DECLARE SUB printtime ()                 ' debbugger tool
  18.  DECLARE SUB printins ()
  19.  
  20.  
  21.  DECLARE SUB p3x5numfnt (x, y, num, colour)        ' fonts
  22.  DECLARE SUB p5x7ascfnt (x, y, text$, colour)
  23.  
  24.  DECLARE SUB createhero ()
  25.  DECLARE SUB createherolaser ()
  26.  
  27.  
  28.  DECLARE SUB createchunks (x, y)
  29.  DECLARE SUB createalienbolt (x, y)
  30.  DECLARE SUB createalienshot (x, y)
  31.  DECLARE SUB createimplode (x, y)
  32.  DECLARE SUB createcolonists ()
  33.  DECLARE SUB creategrabber ()
  34.  DECLARE SUB createmutant (x, y)
  35.  DECLARE SUB createbomer ()
  36.  DECLARE SUB createblocker ()
  37.  DECLARE SUB createspinner ()
  38.  DECLARE SUB createbomb (x, y)
  39.  DECLARE SUB createchaser ()
  40.  DECLARE SUB createspinette (x, y)
  41.  DECLARE SUB createtracker ()
  42.      
  43.  
  44.  DECLARE SUB killsprites ()
  45.  DECLARE SUB collision ()
  46.  DECLARE SUB levels ()
  47.  DECLARE SUB newgame ()
  48.  DECLARE SUB endgame ()
  49.  
  50.  DECLARE SUB traitshero ()
  51.  DECLARE SUB traitsgrabber (a)            ' inteligence for aliens
  52.  DECLARE SUB traitsmutant (a)
  53.  DECLARE SUB traitsbomer (a)
  54.  DECLARE SUB traitsblocker ()
  55.  DECLARE SUB traitsspinner (a)
  56.  DECLARE SUB traitschaser (a)
  57.  DECLARE SUB traitscolonist (a)
  58.  DECLARE SUB traitsspinette ()
  59.  DECLARE SUB traitstracker (a%)
  60.  DECLARE SUB traitsalienshot ()
  61.  
  62.  DECLARE SUB drawplayscreen ()
  63.  DECLARE SUB drawboundrys ()
  64.  DECLARE SUB movesprites ()
  65.  
  66.  
  67.  DECLARE FUNCTION strobe ()              ' returns color
  68.  DECLARE FUNCTION timepassed (n, tsecs!) ' check for passage of time
  69.  DECLARE FUNCTION keyboard ()           ' returns ascii value of key press
  70.  DECLARE FUNCTION joystick ()            ' returns direction of movement
  71.  DECLARE FUNCTION joybutt ()             ' returns number of button pressed
  72.  
  73.  DECLARE FUNCTION adlib ()               ' detects presence of adlib
  74.  DECLARE SUB WriteReg (reg, value)       ' write to adlibs registers
  75.  DECLARE SUB adlibfx (num)               ' plays the sounds
  76.  
  77.  CONST false = 0
  78.  CONST TRUE = NOT false
  79.  
  80.  'CONST speed = 1                  ' set higher for slower computers
  81.  'CONST pageswap = TRUE            ' set page swap (fast computers only)
  82.  'CONST delay = false              ' slow down the game
  83.  
  84.  
  85.  TYPE sprite
  86.     x       AS INTEGER     ' virtual location
  87.     y       AS INTEGER     '
  88.     oldx    AS INTEGER     ' old location for erase
  89.     oldy    AS INTEGER     '
  90.     px      AS INTEGER     ' physical x
  91.     py      AS INTEGER     ' physical y
  92.     cx      AS INTEGER     ' counter
  93.     cy      AS INTEGER     '
  94.     vx      AS INTEGER     ' velocity
  95.     vy      AS INTEGER     '
  96.     rx      AS INTEGER     ' radar x
  97.     ry      AS INTEGER     '
  98.     oldrx   AS INTEGER
  99.     oldry   AS INTEGER
  100.     dirx    AS INTEGER     '
  101.     diry    AS INTEGER
  102.     h       AS INTEGER     ' hight
  103.     w       AS INTEGER     ' width
  104.     mem1    AS INTEGER     ' save something
  105.     mem2    AS INTEGER     '
  106.     eras    AS INTEGER     ' erase
  107.     health  AS INTEGER     ' alive
  108.     dir     AS INTEGER     ' various, usually referenced for movement
  109.     thrust  AS INTEGER     ' for hero ship
  110.     mode    AS INTEGER     ' various
  111.     toplay  AS INTEGER     ' how many to play
  112.     played  AS INTEGER     ' how many have been played
  113.  END TYPE
  114.  
  115.  TYPE explode
  116.    set      AS INTEGER
  117.    x        AS INTEGER
  118.    y        AS INTEGER
  119.    size     AS INTEGER
  120.    colour   AS INTEGER
  121.    c1       AS INTEGER
  122.    c2       AS INTEGER
  123.  END TYPE
  124.  
  125.  'global variables
  126.  
  127.  COMMON SHARED Pageswap, speed, keyspeed, delay
  128.  
  129.  COMMON SHARED minx, miny, maxx, maxy, topy, boty, qtrx, thrdx
  130.  COMMON SHARED fieldw, fieldh, fieldx
  131.  COMMON SHARED radarx, radary, radarsx, radarsy, radarw, radarh, radarwrapx
  132.  COMMON SHARED pickup
  133.  COMMON SHARED level, newlevel
  134.  
  135.  COMMON SHARED maxaliensinplay, aliensinplay
  136.  COMMON SHARED hero AS sprite, heroimage()   AS INTEGER
  137.  COMMON SHARED grabber() AS sprite, maxgrabbers, numgrabbers
  138.  COMMON SHARED chaser AS sprite
  139.  COMMON SHARED mutant() AS sprite
  140.  COMMON SHARED bomer() AS sprite, maxbomers, numbomers
  141.  COMMON SHARED bomb AS sprite
  142.  COMMON SHARED blocker AS sprite, maxblockers
  143.  COMMON SHARED spinner AS sprite, maxspinners
  144.  COMMON SHARED spinette AS sprite
  145.  COMMON SHARED col() AS sprite, maxcolonists
  146.  COMMON SHARED herolaser() AS sprite, maxherolasers
  147.  COMMON SHARED alienshot AS sprite
  148.  COMMON SHARED alienbolt() AS sprite, maxalienbolts
  149.  COMMON SHARED tracker AS sprite
  150.  
  151.  COMMON SHARED chunk() AS sprite, maxchunks
  152.  COMMON SHARED exp1 AS explode
  153.  
  154.                                  '  set variables to maximum array sizes
  155.  maxaliensinplay = 10            '  most on playfield
  156.  maxherolasers = 0               '
  157.  maxalienbolts = 0
  158.  maxcolonists = 10
  159.  maxgrabbers = 15
  160.  maxbomers = 2
  161.  maxchunks = 20
  162.  
  163.  speed = 1
  164.  keyspeed = 8
  165.  delay = 0
  166.  
  167.  DIM herolaser(maxherolasers) AS sprite
  168.  DIM alienbolt(maxalienbolts) AS sprite
  169.  DIM col(maxcolonists)  AS sprite
  170.  DIM grabber(maxgrabbers) AS sprite
  171.  DIM mutant(maxcolonists) AS sprite
  172.  DIM bomer(maxbomers) AS sprite
  173.  DIM chunk(maxchunks)  AS sprite
  174.  
  175.  
  176.  RANDOMIZE TIMER
  177.  DEF fnrnd (num) = INT(RND * num)         ' returns random number
  178.  
  179.  OUT &H60, &HF3         ' fast typematic rate with min delay
  180.  SLEEP (1)              ' let hardware settle
  181.  OUT &H60, 0
  182.  
  183.  printme
  184.  printins
  185.  
  186.  IF adlib THEN
  187.     adlibsound = TRUE
  188.     PRINT "Adlib detected"
  189.     SLEEP (1)
  190.  END IF
  191.  
  192.  IF joystick = -99 THEN
  193.     PRINT joystick
  194.     PRINT "There was no joystick detected. Unfortunatly QBdefender will"
  195.     PRINT "not opperate correctly without one. You may use the numeric"
  196.     PRINT "keypad to move and shoot but the control will be disapointing."
  197.     PRINT "Press any key."
  198.     DO: LOOP WHILE INKEY$ = ""
  199.  END IF
  200.  
  201.  
  202.  
  203.  a = timepassed(20, 0)                    ' set up counters
  204.  setfxmode                                ' set screen mode and variables
  205.  
  206.  p3x5numfnt -999, 0, 0, 0                   ' load fonts
  207.  p5x7ascfnt -999, 0, "", 0
  208.  
  209. createhero
  210.  
  211.   DO
  212.     levels
  213.     endgame
  214.     starfield
  215.     processgpi
  216.     collision
  217.     movesprites
  218.     creategrabber
  219.     createbomer
  220.     createchaser
  221.     createspinner
  222.     createtracker
  223.     IF Pageswap THEN PCOPY 1, 0
  224.     FOR i = 1 TO delay: NEXT
  225.     'LOCATE 1, 1: PRINT delay
  226.   LOOP
  227.  
  228. FUNCTION adlib
  229.  
  230.   '  Detects an AdLib-compatible card.
  231.   '  Returns 1 (true) if detected and 0 (false) if not.
  232.   
  233.  
  234.    CALL WriteReg(&H4, &H60)  '  Resets both Timers
  235.    CALL WriteReg(&H4, &H80)  '  Enables Interrupts
  236.    b = INP(&H388)            '  Store the result
  237.    CALL WriteReg(&H2, &HFF)  '  Write FFh to register 2 (Timer 1)
  238.    CALL WriteReg(&H4, &H21)  '  Start Timer 1
  239.  
  240.    FOR x = 0 TO 130          '  Delay for 80 Microseconds
  241.       a = INP(&H388)
  242.    NEXT x
  243.  
  244.    c = INP(&H388)                 '  Store the result
  245.    CALL WriteReg(&H4, &H60)       '  Reset Timers
  246.    CALL WriteReg(&H4, &H80)       '  Reset Interrrupts
  247.    Success = 0
  248.    IF (b AND &HE0) = &H0 THEN     '  Test result
  249.      IF (c AND &HE0) = &HC0 THEN  '  Test Result
  250.        Success = 1
  251.        FOR q = 1 TO &HF5          '  clear registers
  252.          CALL WriteReg(q, 0)
  253.        NEXT q
  254.      END IF
  255.    END IF
  256.    adlib = Success
  257.  
  258.  
  259. END FUNCTION
  260.  
  261. SUB adlibfx (num)
  262.  
  263.  SELECT CASE (num)
  264.  
  265.  CASE (0)                    '   mutant exploding
  266.  
  267.  
  268.    WriteReg &HB0, &H0
  269.    numberl = 60
  270.    numberh = 1
  271.    block = 0
  272.                                  ' Modulator
  273.    CALL WriteReg(&H20, &H0)      ' Multiple - 0 to F
  274.    CALL WriteReg(&H40, &H0)      ' Attenuation Level -  0 to 3F
  275.    CALL WriteReg(&H60, &HA5)     ' Attack: (High byte)    Decay: (Low byte)
  276.    CALL WriteReg(&H80, &H0)      ' Sustain: (High byte)   Release: (Low byte)
  277.    CALL WriteReg(&HE0, &HF0)     ' Waveform select  0 to 3
  278.                                 ' Carrier
  279.    CALL WriteReg(&H23, &H0)      ' Multiple  - 0 to F
  280.    CALL WriteReg(&H43, &H0)      ' Attenuation level -  0 to 3F
  281.    CALL WriteReg(&H63, &HA6)     ' Attack: (High byte)   Decay:(low byte)
  282.    CALL WriteReg(&H83, &HAA)     ' Sustain: (High Byte)  Release:(low byte)
  283.    CALL WriteReg(&HE1, &HF0)     ' Waveform select  0 to 3
  284.  
  285.    keyon% = &H20
  286.  
  287.    Byte% = keyon% + (block * 4) + numberh%
  288.  
  289.    CALL WriteReg(&HA0, numberl)     ' F-Number(L)  0 to 255
  290.    CALL WriteReg(&HB0, Byte%)     ' Sound voice ,Set block ,Set F-Number(H)
  291.  
  292.  
  293.  CASE 1                 'hero firing
  294.  
  295.   WriteReg &HB1, &H0
  296.  
  297.   numberl = 230
  298.   numberh = 1
  299.   block = 1
  300.                               ' Modulator
  301.   CALL WriteReg(&H21, &H10)    ' Multiple - 0 to F
  302.   CALL WriteReg(&H41, &H0)    ' Attenuation Level -  0 to 3F
  303.   CALL WriteReg(&H61, &H66)   ' Attack: (High byte)    Decay: (Low byte)
  304.   CALL WriteReg(&H81, &HF6)   ' Sustain: (High byte)   Release: (Low byte)
  305.   CALL WriteReg(&HE1, &HF2)   ' Waveform select  0 to 3
  306.                               ' Carrier
  307.   CALL WriteReg(&H24, &H0)    ' Multiple  - 0 to F
  308.   CALL WriteReg(&H44, &H6)    ' Attenuation level -  0 to 3F
  309.   CALL WriteReg(&H64, &H63)   ' Attack: (High byte)   Decay:(low byte)
  310.   CALL WriteReg(&H84, &HF8)    ' Sustain: (High Byte)  Release:(low byte)
  311.   CALL WriteReg(&HE4, &HF0)   ' Waveform select  0 to 3
  312.  
  313.   keyon = &H20
  314.  
  315.   Byte = keyon + (block * 4) + (numberh)
  316.  
  317.   CALL WriteReg(&HC1, 0)            ' conection
  318.   CALL WriteReg(&HC1, 0)            ' conection
  319.   CALL WriteReg(&HA1, numberl)     ' F-Number(L)  0 to 255
  320.   CALL WriteReg(&HB1, Byte)     ' Sound voice ,Set block ,Set F-Number(H)
  321.  
  322.   '  WriteReg &HB1, &H0          ' stop noise
  323.  
  324.   '  numberl = 10
  325.   '  numberh = 0
  326.    ' block = 7
  327.                                 ' Modulator
  328.   '  CALL WriteReg(&H21, &H3)     ' Multiple - 0 to F
  329.   '  CALL WriteReg(&H41, &H0)    ' Attenuation Level -  0 to 3F
  330.   '  CALL WriteReg(&H61, &H99)   ' Attack: (High byte)    Decay: (Low byte)
  331.   '  CALL WriteReg(&H81, &HFF)   ' Sustain: (High byte)   Release: (Low byte)
  332.   '  CALL WriteReg(&HE1, &HF0)   ' Waveform select  0 to 3
  333.                                 ' Carrier
  334.   '  CALL WriteReg(&H24, &H1)    ' Multiple  - 0 to F
  335.   '  CALL WriteReg(&H44, &H0)    ' Attenuation level -  0 to 3F
  336.   '  CALL WriteReg(&H64, &HAD)   ' Attack: (High byte)   Decay:(low byte)
  337.    ' CALL WriteReg(&H84, &H55)   ' Sustain: (High Byte)  Release:(low byte)
  338.   '  CALL WriteReg(&HE4, &HF0)   ' Waveform select  0 to 3
  339.  
  340.   '  keyon% = &H20
  341.  
  342.   '  Byte% = keyon% + (block * 4) + numberh
  343.  
  344.   ' CALL WriteReg(&HA1, numberl)     ' F-Number(L)  0 to 255
  345.   ' CALL WriteReg(&HB1, Byte)     ' Sound voice ,Set block ,Set F-Number(H)
  346.  
  347.  
  348.  
  349.  CASE 2                       ' colonist pick up warning
  350.  
  351.   WriteReg &HB2, &H0          ' stop noise
  352.  
  353.   numberl = 255
  354.   numberh = 3
  355.   block = 2
  356.                               ' Modulator
  357.   CALL WriteReg(&H22, &H3)    ' Multiple - 0 to F
  358.   CALL WriteReg(&H42, &H0)    ' Attenuation Level -  0 to 3F
  359.   CALL WriteReg(&H62, &H5F)   ' Attack: (High byte)    Decay: (Low byte)
  360.   CALL WriteReg(&H82, &HFF)   ' Sustain: (High byte)   Release: (Low byte)
  361.   CALL WriteReg(&HE2, &HF0)   ' Waveform select  0 to 3
  362.                               ' Carrier
  363.   CALL WriteReg(&H25, &H0)    ' Multiple  - 0 to F
  364.   CALL WriteReg(&H45, &H9)    ' Attenuation level -  0 to 3F
  365.   CALL WriteReg(&H65, &H5F)   ' Attack: (High byte)   Decay:(low byte)
  366.   CALL WriteReg(&H85, &HFF)   ' Sustain: (High Byte)  Release:(low byte)
  367.   CALL WriteReg(&HE5, &HF0)   ' Waveform select  0 to 3
  368.  
  369.   keyon% = &H20
  370.  
  371.   Byte% = keyon% + (block * 4) + numberh
  372.  
  373.   CALL WriteReg(&HA2, numberl)     ' F-Number(L)  0 to 255
  374.   CALL WriteReg(&HB2, Byte)     ' Sound voice ,Set block ,Set F-Number(H)
  375.  
  376.  
  377.  CASE 3                         ' mutant converted
  378.     WriteReg &HB3, &H0
  379.  
  380.     numberl = 10
  381.     numberh = 0
  382.     block = 5
  383.                                 ' Modulator
  384.     CALL WriteReg(&H28, &H5)     ' Multiple - 0 to F
  385.     CALL WriteReg(&H48, &H0)    ' Attenuation Level -  0 to 3F
  386.     CALL WriteReg(&H68, &H99)   ' Attack: (High byte)    Decay: (Low byte)
  387.     CALL WriteReg(&H88, &HFF)   ' Sustain: (High byte)   Release: (Low byte)
  388.     CALL WriteReg(&HE8, &HF0)   ' Waveform select  0 to 3
  389.                                 ' Carrier
  390.     CALL WriteReg(&H2B, &H0)    ' Multiple  - 0 to F
  391.     CALL WriteReg(&H4B, &H0)    ' Attenuation level -  0 to 3F
  392.     CALL WriteReg(&H6B, &HAD)   ' Attack: (High byte)   Decay:(low byte)
  393.     CALL WriteReg(&H8B, &H55)   ' Sustain: (High Byte)  Release:(low byte)
  394.     CALL WriteReg(&HEB, &HF0)   ' Waveform select  0 to 3
  395.  
  396.     keyon% = &H20
  397.  
  398.     Byte% = keyon% + (block * 4) + numberh
  399.  
  400.    CALL WriteReg(&HA3, numberl)     ' F-Number(L)  0 to 255
  401.    CALL WriteReg(&HB3, Byte)     ' Sound voice ,Set block ,Set F-Number(H)
  402.  
  403.  CASE 4           ' mutant firing
  404.  
  405.     WriteReg &HB4, &H0          ' stop noise
  406.  
  407.     numberl = 10
  408.     numberh = 0
  409.     block = 1
  410.                                 ' Modulator
  411.     CALL WriteReg(&H29, &H5)     ' Multiple - 0 to F
  412.     CALL WriteReg(&H49, &H0)    ' Attenuation Level -  0 to 3F
  413.     CALL WriteReg(&H69, &H87)   ' Attack: (High byte)    Decay: (Low byte)
  414.     CALL WriteReg(&H89, &HFF)   ' Sustain: (High byte)   Release: (Low byte)
  415.     CALL WriteReg(&HE9, &HF0)   ' Waveform select  0 to 3
  416.                                 ' Carrier
  417.     CALL WriteReg(&H2C, &H1)    ' Multiple  - 0 to F
  418.     CALL WriteReg(&H4C, &H9)    ' Attenuation level -  0 to 3F
  419.     CALL WriteReg(&H6C, &HA5)   ' Attack: (High byte)   Decay:(low byte)
  420.     CALL WriteReg(&H8C, &H55)   ' Sustain: (High Byte)  Release:(low byte)
  421.     CALL WriteReg(&HEC, &HF0)   ' Waveform select  0 to 3
  422.  
  423.     keyon% = &H20
  424.  
  425.     Byte% = keyon% + (block * 4) + numberh
  426.  
  427.    CALL WriteReg(&HA4, numberl)     ' F-Number(L)  0 to 255
  428.    CALL WriteReg(&HB4, Byte)     ' Sound voice ,Set block ,Set F-Number(H)
  429.  
  430.  CASE 5
  431.  
  432.    'PRINT " bomer noise"
  433.    WriteReg &HB5, &H0          ' stop noise
  434.  
  435.     numberl = 60
  436.     numberh = 1
  437.     block = 2
  438.                                 ' Modulator
  439.     CALL WriteReg(&H2A, &H0)    ' Multiple - 0 to F
  440.     CALL WriteReg(&H4A, &H0)    ' Attenuation Level -  0 to 3F
  441.     CALL WriteReg(&H6A, &H55)   ' Attack: (High byte)    Decay: (Low byte)
  442.     CALL WriteReg(&H8A, &HAA)   ' Sustain: (High byte)   Release: (Low byte)
  443.     CALL WriteReg(&HEA, &HF3)   ' Waveform select  0 to 3
  444.                                 ' Carrier
  445.     CALL WriteReg(&H2D, &H0)    ' Multiple  - 0 to F
  446.     CALL WriteReg(&H4D, &H0)    ' Attenuation level -  0 to 3F
  447.     CALL WriteReg(&H6D, &HFF)   ' Attack: (High byte)   Decay:(low byte)
  448.     CALL WriteReg(&H8D, &HAA)   ' Sustain: (High Byte)  Release:(low byte)
  449.     CALL WriteReg(&HED, &HF3)   ' Waveform select  0 to 3
  450.  
  451.  
  452.    CALL WriteReg(&HC5, 1)            ' conection
  453.  
  454.    keyon% = &H20
  455.  
  456.    Byte% = keyon% + (block * 4) + numberh
  457.  
  458.    CALL WriteReg(&HA5, numberl)     ' F-Number(L)  0 to 255
  459.    CALL WriteReg(&HB5, Byte)     ' Sound voice ,Set block ,Set F-Number(H)
  460.  
  461.  
  462.   CASE 6
  463.  
  464.    WriteReg &HB4, &H0
  465.    numberl = 130
  466.    numberh = 0
  467.    block = 0
  468.                                  ' Modulator
  469.    CALL WriteReg(&H29, &H0)      ' Multiple - 0 to F
  470.    CALL WriteReg(&H49, &H0)      ' Attenuation Level -  0 to 3F
  471.    CALL WriteReg(&H69, &HA5)     ' Attack: (High byte)    Decay: (Low byte)
  472.    CALL WriteReg(&H89, &H0)      ' Sustain: (High byte)   Release: (Low byte)
  473.    CALL WriteReg(&HE9, &HF0)     ' Waveform select  0 to 3
  474.                                 ' Carrier
  475.    CALL WriteReg(&H2C, &H0)      ' Multiple  - 0 to F
  476.    CALL WriteReg(&H4C, &H0)      ' Attenuation level -  0 to 3F
  477.    CALL WriteReg(&H6C, &HA6)     ' Attack: (High byte)   Decay:(low byte)
  478.    CALL WriteReg(&H8C, &H55)     ' Sustain: (High Byte)  Release:(low byte)
  479.    CALL WriteReg(&HEC, &HF0)     ' Waveform select  0 to 3
  480.  
  481.    keyon% = &H20
  482.  
  483.    Byte% = keyon% + (block * 4) + numberh%
  484.  
  485.    CALL WriteReg(&HA4, numberl)     ' F-Number(L)  0 to 255
  486.    CALL WriteReg(&HB4, Byte%)     ' Sound voice ,Set block ,Set F-Number(H)
  487.  
  488.  
  489.  
  490.  END SELECT
  491.  
  492. END SUB
  493.  
  494. SUB collision
  495.  
  496.  ' detect collisions
  497.  
  498.  SHARED collidex, collidey    ' for chunks
  499.  SHARED pickup
  500.  
  501.  STATIC top(), left(), bottom(), right(), didthis
  502.  
  503.   IF didthis = 0 THEN
  504.     DIM top(1)
  505.     DIM left(1)
  506.     DIM bottom(1)
  507.     DIM right(1)
  508.     didthis = 1
  509.   END IF
  510.  
  511.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  512.  '│││││││││││││││││││ Check hero ship against grabbers. │││││││││││││││││││││
  513.  
  514.  
  515.   FOR a = 0 TO maxgrabbers
  516.     IF NOT (grabber(a).x < 0) OR (grabber(a).x > maxx) THEN
  517.       'IF (grabber(a).y > hero.y + hero.h) THEN EXIT FOR
  518.       'IF (grabber(a).y + grabber(a).h < hero.y) THEN EXIT FOR
  519.       IF (grabber(a).health > 0) AND (hero.health > 0) THEN
  520.      
  521.        top(0) = hero.y
  522.        left(0) = hero.x
  523.        bottom(0) = hero.y + hero.h
  524.        right(0) = hero.x + hero.w
  525.   
  526.        top(1) = grabber(a).y
  527.        left(1) = grabber(a).x
  528.        bottom(1) = grabber(a).y + grabber(a).h
  529.        right(1) = grabber(a).x + grabber(a).w
  530.  
  531.     IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  532.     
  533.     ELSE
  534.       grabber(a).health = grabber(a).health - 1
  535.       hero.health = hero.health - 1
  536.     END IF
  537.   END IF
  538.   END IF
  539.  
  540.  NEXT
  541.  
  542.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  543.  '│││││││││││││││││││ Check hero ship against mutants. ││││││││││││││││││││││
  544.  
  545.  
  546.   FOR a = 0 TO maxcolonists
  547.     IF NOT (mutant(a).x < 0) OR (mutant(a).x > maxx) THEN
  548.       'IF (mutant(a).y > hero.y + hero.h) THEN EXIT FOR
  549.       'IF (mutant(a).y + mutant(a).h < hero.y) THEN EXIT FOR
  550.       IF mutant(a).health THEN 'AND hero.health THEN
  551.     
  552.        top(0) = hero.y
  553.        left(0) = hero.x
  554.        bottom(0) = hero.y + hero.h
  555.        right(0) = hero.x + hero.w
  556.  
  557.        top(1) = mutant(a).y
  558.        left(1) = mutant(a).x
  559.        bottom(1) = mutant(a).y + mutant(a).h
  560.        right(1) = mutant(a).x + mutant(a).w
  561.  
  562.     IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  563.    
  564.     ELSE
  565.       mutant(a).health = mutant(a).health - 1
  566.       hero.health = hero.health - 1
  567.       createchunks hero.x, hero.y
  568.     END IF
  569.   END IF
  570.   END IF
  571.  
  572. NEXT
  573.  
  574.  
  575.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  576.  '│││││││││││││││││││ Check hero ship against alienshots. │││││││││││││││││││
  577.  
  578.       IF alienshot.health THEN
  579.       
  580.        top(0) = hero.y
  581.        left(0) = hero.x
  582.        bottom(0) = hero.y + hero.h
  583.        right(0) = hero.x + hero.w
  584.  
  585.        top(1) = alienshot.y
  586.        left(1) = alienshot.x
  587.        bottom(1) = alienshot.y + alienshot.h
  588.        right(1) = alienshot.x + alienshot.w
  589.  
  590.     IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  591.     ELSE
  592.       alienshot.health = 0
  593.       IF hero.mode = 1 THEN              ' holding coloinist
  594.         col(hero.mem1).health = 0        ' colonist takes shot
  595.         pickup = 0                       ' another may be picked up
  596.         hero.mode = 0
  597.       ELSE
  598.         hero.health = hero.health - 1
  599.       END IF
  600.       createchunks hero.x, hero.y
  601.     END IF
  602.   END IF
  603.  
  604.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  605.  '│││││││││││││││││││ Check hero ship against spinettes. ││││││││││││││││││││
  606.  
  607.     
  608.       IF spinette.health THEN
  609.      
  610.        top(0) = hero.y
  611.        left(0) = hero.x
  612.        bottom(0) = hero.y + hero.h
  613.        right(0) = hero.x + hero.w
  614.  
  615.        top(1) = spinette.y
  616.        left(1) = spinette.x
  617.        bottom(1) = spinette.y + spinette.h
  618.        right(1) = spinette.x + spinette.w
  619.  
  620.     IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  621.     ELSE
  622.       spinette.health = 0
  623.       IF hero.mode = 1 THEN              ' holding coloinist
  624.         col(hero.mem1).health = 0        ' colonist takes shot
  625.         pickup = 0                       ' another may be picked up
  626.         hero.mode = 0
  627.       ELSE
  628.         hero.health = hero.health - 1
  629.       END IF
  630.       createchunks hero.x, hero.y
  631.     END IF
  632.   END IF
  633.  
  634.  
  635.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  636.  '│││││││││││││││││││ Check hero ship against colonists. ││││││││││││││││││││
  637.  
  638.  
  639.   FOR a = 0 TO maxcolonists
  640.       IF col(a).health AND col(a).mode = 1 AND col(a).dir = 0 THEN
  641.   
  642.       IF (col(a).y > hero.y + hero.h) THEN EXIT FOR
  643.       IF (col(a).y + col(a).h < hero.y) THEN EXIT FOR
  644.         
  645.        top(0) = hero.y
  646.        left(0) = hero.x
  647.        bottom(0) = hero.y + hero.h
  648.        right(0) = hero.x + hero.w
  649.  
  650.        top(1) = col(a).y
  651.        left(1) = col(a).x
  652.        bottom(1) = col(a).y + col(a).h
  653.        right(1) = col(a).x + col(a).w
  654.  
  655.     IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  656.  
  657.     ELSE
  658.       
  659.       col(a).mode = 2
  660.       hero.mode = 1
  661.       hero.mem1 = a
  662.       
  663.     END IF
  664.  
  665.   END IF
  666.  
  667. NEXT
  668.  
  669.  
  670.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  671.  '│││││││││││││││││││ Check hero lasers against grabbers. │││││││││││││││││││
  672.    
  673.     FOR a = 0 TO maxherolasers
  674.      IF herolaser(a).health THEN    ' don't bother if missle is dead
  675.         IF herolaser(a).dir = 1 THEN
  676.          top(0) = herolaser(a).y
  677.          left(0) = herolaser(a).x
  678.          bottom(0) = herolaser(a).y
  679.          right(0) = herolaser(a).x
  680.          ELSEIF herolaser(a).dir = 0 THEN
  681.          top(0) = herolaser(a).y
  682.          left(0) = herolaser(a).x
  683.          bottom(0) = herolaser(a).y
  684.          right(0) = herolaser(a).x
  685.         END IF
  686.  
  687.  
  688.  
  689.       FOR b = 0 TO maxgrabbers
  690.       IF (grabber(b).x > minx) OR (grabber(b).x < maxx) THEN
  691.         IF grabber(b).health THEN       ' don't bother if grabber is dead
  692.  
  693.           top(1) = grabber(b).y
  694.           left(1) = grabber(b).x
  695.           bottom(1) = grabber(b).y + grabber(b).h
  696.           right(1) = grabber(b).x + grabber(b).w
  697.            
  698.           IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  699.  
  700.           ELSE
  701.             grabber(b).health = grabber(b).health - 1
  702.             herolaser(a).health = false
  703.             IF grabber(b).health = 0 THEN
  704.              adlibfx (0)
  705.              'adlibfx (6)
  706.              IF exp1.set = 0 THEN
  707.               exp1.set = 1
  708.               exp1.x = herolaser(a).x
  709.               exp1.y = herolaser(a).y
  710.               exp1.size = 15
  711.               exp1.colour = 2
  712.              END IF
  713.              END IF
  714.           END IF
  715.         END IF
  716.        END IF
  717.        NEXT b
  718.      
  719.     END IF
  720.    NEXT a
  721.  
  722.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  723.  '│││││││││││││││││││ Check hero lasers against mutants │││││││││││││││││││││
  724.  
  725.     FOR a = 0 TO maxherolasers
  726.      IF herolaser(a).health THEN
  727.  
  728.          top(0) = herolaser(a).y
  729.          left(0) = herolaser(a).x
  730.          bottom(0) = herolaser(a).y
  731.          right(0) = herolaser(a).x
  732.      
  733.       FOR b = 0 TO maxcolonists
  734.  
  735.          IF mutant(b).health THEN       ' don't bother if mutant is dead
  736.           top(1) = mutant(b).y
  737.           left(1) = mutant(b).x
  738.           bottom(1) = mutant(b).y + mutant(b).h
  739.           right(1) = mutant(b).x + mutant(b).w
  740.           
  741.           IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  742.  
  743.           ELSE
  744.             mutant(b).health = mutant(b).health - 1
  745.             herolaser(a).health = false
  746.             adlibfx (0)
  747.             IF mutant(b).health = 0 THEN
  748.              createchunks herolaser(a).x, herolaser(a).y
  749.              adlibfx (0)
  750.              IF exp1.set = 0 THEN
  751.               exp1.set = 1
  752.               exp1.x = herolaser(a).x
  753.               exp1.y = herolaser(a).y
  754.               exp1.size = 15
  755.               exp1.colour = 4
  756.              END IF
  757.  
  758.             END IF
  759.            
  760.           END IF
  761.         END IF
  762.         NEXT b
  763.      END IF
  764.     
  765.    NEXT a
  766.  
  767.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  768.  '│││││││││││││││││││ Check hero lasers against bomers. │││││││││││││││││││││
  769.  
  770.  
  771.     FOR a = 0 TO maxherolasers
  772.      IF herolaser(a).health THEN
  773.      IF herolaser(a).dir THEN
  774.          top(0) = herolaser(a).y
  775.          left(0) = herolaser(a).x
  776.          bottom(0) = herolaser(a).y
  777.          right(0) = herolaser(a).x
  778.        ELSE
  779.          top(0) = herolaser(a).y
  780.          left(0) = herolaser(a).x
  781.          bottom(0) = herolaser(a).y
  782.          right(0) = herolaser(a).x
  783.        END IF
  784.  
  785.       FOR b = 0 TO maxbomers
  786.         IF (bomer(b).x > minx) AND (bomer(b).x < maxx) THEN
  787.          IF bomer(b).health THEN
  788.           top(1) = bomer(b).y
  789.           left(1) = bomer(b).x
  790.           bottom(1) = bomer(b).y + bomer(b).h
  791.           right(1) = bomer(b).x + bomer(b).w
  792.          
  793.           IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  794.  
  795.           ELSE
  796.             bomer(b).health = bomer(b).health - 1
  797.             herolaser(a).health = false
  798.             adlibfx (0)
  799.             IF bomer(b).health = 0 THEN
  800.              createchunks herolaser(a).x, herolaser(a).y
  801.              'adlibfx (0)
  802.              adlibfx (6)
  803.              IF exp1.set = 0 THEN
  804.               exp1.set = 1
  805.               exp1.x = herolaser(a).x
  806.               exp1.y = herolaser(a).y
  807.               exp1.size = 15
  808.               exp1.colour = 3
  809.              END IF
  810.  
  811.             END IF
  812.           
  813.           END IF
  814.         END IF
  815.         END IF
  816.        NEXT b
  817.      END IF
  818.    
  819.    NEXT a
  820.  
  821.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  822.  '│││││││││││││││││││ Check hero lasers against blockers. │││││││││││││││││││
  823.  
  824.     FOR a = 0 TO maxherolasers
  825.      IF herolaser(a).health THEN       ' don't bother if missle is dead
  826.        IF herolaser(a).dir THEN
  827.          top(0) = herolaser(a).y
  828.          left(0) = herolaser(a).x
  829.          bottom(0) = herolaser(a).y
  830.          right(0) = herolaser(a).x
  831.        ELSE
  832.          top(0) = herolaser(a).y
  833.          left(0) = herolaser(a).x
  834.          bottom(0) = herolaser(a).y
  835.          right(0) = herolaser(a).x
  836.        END IF
  837.  
  838.        IF (blocker.x > minx) AND (blocker.x < maxx) THEN
  839.          IF blocker.health THEN       ' don't bother if mutant is dead
  840.           top(1) = blocker.y
  841.           left(1) = blocker.x
  842.           bottom(1) = blocker.y + blocker.h
  843.           right(1) = blocker.x + blocker.w
  844.         
  845.           IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  846.  
  847.           ELSE
  848.             blocker.health = blocker.health - 1
  849.             createchunks herolaser(a).x, herolaser(a).y
  850.             blocker.vy = 0
  851.             IF blocker.health = 0 THEN
  852.             hero.vx = hero.mem2           ' restore hero x velocity
  853.              adlibfx (0)
  854.             END IF
  855.          
  856.           END IF
  857.         END IF
  858.         END IF
  859.        
  860.      END IF
  861.   
  862.    NEXT a
  863.  
  864.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  865.  '│││││││││││││││││││ Check hero lasers against spinners ││││││││││││││││││││
  866.  
  867.  
  868.     FOR a = 0 TO maxherolasers
  869.      IF herolaser(a).health THEN       ' don't bother if laser is dead
  870.  
  871.          top(0) = herolaser(a).y
  872.          left(0) = herolaser(a).x
  873.          bottom(0) = herolaser(a).y
  874.          right(0) = herolaser(a).x
  875.       
  876.       
  877.         IF (spinner.x > minx) AND (spinner.x < maxx) THEN
  878.          IF spinner.health THEN       ' don't bother if mutant is dead
  879.           top(1) = spinner.y - spinner.w
  880.           left(1) = spinner.x - spinner.w
  881.           bottom(1) = spinner.y + spinner.w
  882.           right(1) = spinner.x + spinner.w
  883.        
  884.           IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  885.  
  886.           ELSE
  887.             spinner.health = spinner.health - 1
  888.             createchunks herolaser(a).x, herolaser(a).y
  889.             herolaser(a).health = 0
  890.             IF spinner.health = 0 THEN
  891.               adlibfx (0)
  892.               adlibfx (6)
  893.               IF exp1.set = 0 THEN
  894.                exp1.set = 1
  895.                exp1.x = herolaser(a).x
  896.                exp1.y = herolaser(a).y
  897.                exp1.size = 15
  898.                exp1.colour = 9
  899.               END IF
  900.             END IF
  901.           END IF
  902.         END IF
  903.         END IF
  904.        
  905.      END IF
  906.  
  907.    NEXT a
  908.  
  909.  
  910.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  911.  '│││││││││││││││││││ Check hero ship against blockers. │││││││││││││││││││││
  912.  
  913.     
  914.      IF blocker.health THEN
  915.        IF (blocker.x > minx) AND (blocker.x < maxx) THEN
  916.  
  917.          top(0) = hero.y
  918.          left(0) = hero.x
  919.          bottom(0) = hero.y + hero.h
  920.          right(0) = hero.x + hero.w
  921.         
  922.          top(1) = blocker.y
  923.          left(1) = blocker.x
  924.          bottom(1) = blocker.y + blocker.h
  925.          right(1) = blocker.x + blocker.w
  926.         
  927.          IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  928.          ELSE
  929.           IF blocker.mem1 = hero.dir THEN hero.vx = 0
  930.               hero.y = blocker.y
  931.             END IF
  932.       END IF
  933.      END IF
  934.    
  935.   
  936.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  937.  '│││││││││││││││││││ Check hero ship against chasers. ││││││││││││││││││││││
  938.  
  939.   
  940.      IF chaser.health THEN
  941.        IF (chaser.x > minx) AND (chaser.x < maxx) THEN
  942.  
  943.           top(0) = hero.y
  944.           left(0) = hero.x
  945.           bottom(0) = hero.y + hero.h
  946.           right(0) = hero.x + hero.w
  947.         
  948.           top(1) = chaser.y
  949.           left(1) = chaser.x
  950.           bottom(1) = chaser.y + chaser.h
  951.           right(1) = chaser.x + chaser.w
  952.  
  953.         
  954.          IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  955.  
  956.          ELSE
  957.           
  958.       '      hero.health = hero.health - 1
  959.             chaser.health = 0
  960.             adlibfx (0)
  961.             createchunks chaser.x, chaser.y
  962.             createchunks chaser.x, chaser.y
  963.  
  964.          END IF
  965.        END IF
  966.       END IF
  967.  
  968.  
  969.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  970.  '│││││││││││││││││││ Check hero lasers against chasers. ││││││││││││││││││││
  971.  
  972.   
  973.      IF chaser.health THEN
  974.        IF (chaser.x > minx) AND (chaser.x < maxx) THEN
  975.          IF NOT (chaser.y > hero.y + hero.h) AND NOT (chaser.y < hero.y) THEN
  976.  
  977.            FOR a = 0 TO maxherolasers
  978.  
  979.             top(0) = herolaser(a).y
  980.             left(0) = herolaser(a).x
  981.             bottom(0) = herolaser(a).y
  982.             right(0) = herolaser(a).x
  983.         
  984.             top(1) = chaser.y
  985.             left(1) = chaser.x
  986.             bottom(1) = chaser.y + chaser.h
  987.             right(1) = chaser.x + chaser.w
  988.  
  989.         
  990.          IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  991.  
  992.          ELSE
  993.            
  994.             chaser.health = 0
  995.             createchunks chaser.x, chaser.y
  996.             adlibfx (0)
  997.             adlibfx (6)
  998.              IF exp1.set = 0 THEN
  999.               exp1.set = 1
  1000.               exp1.x = herolaser(a).x
  1001.               exp1.y = herolaser(a).y
  1002.               exp1.size = 15
  1003.               exp1.colour = 15
  1004.              END IF
  1005.  
  1006.          END IF
  1007.        NEXT a
  1008.        END IF
  1009.        END IF
  1010.       END IF
  1011.  
  1012.  
  1013.  
  1014.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  1015.  '│││││││││││││││││││ Check hero ship against alienbombs. │││││││││││││││││││
  1016.  
  1017.  
  1018.      IF bomb.health THEN
  1019.        top(0) = hero.y
  1020.        left(0) = hero.x
  1021.        bottom(0) = hero.y + hero.h
  1022.        right(0) = hero.x + hero.w
  1023.  
  1024.        top(1) = bomb.y
  1025.        left(1) = bomb.x
  1026.        bottom(1) = bomb.y + bomb.h
  1027.        right(1) = bomb.x + bomb.w
  1028.  
  1029.       
  1030.          IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  1031.  
  1032.          ELSE
  1033.            
  1034.            bomb.health = 0
  1035.            hero.health = hero.health - 1
  1036.            createchunks bomb.x, bomb.y
  1037.            createchunks bomb.x, bomb.y
  1038.            createchunks bomb.x, bomb.y
  1039.          END IF
  1040.        END IF
  1041.       
  1042.     
  1043.   
  1044.  
  1045.  
  1046.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  1047.  '│││││││││││││││││││ Check hero lasers against colonists. ││││││││││││││││││
  1048.  
  1049.  
  1050. '    FOR a = 0 TO maxherolasers
  1051. '     IF col(a).y < maxy - col(a).h THEN
  1052. '      IF (col(a).x > minx) AND (col(a).x < maxx) THEN
  1053. '       IF herolaser(a).health THEN
  1054. '         IF herolaser(a).dir THEN
  1055. '           top(0) = herolaser(a).y
  1056. '           left(0) = herolaser(a).x
  1057. '           bottom(0) = herolaser(a).y
  1058. '           right(0) = herolaser(a).x
  1059. '         ELSE
  1060. '           top(0) = herolaser(a).y
  1061. '           left(0) = herolaser(a).x
  1062. '           bottom(0) = herolaser(a).y
  1063. '           right(0) = herolaser(a).x
  1064. '         END IF
  1065. '
  1066. '      FOR b = 0 TO maxcolonists
  1067. '        IF col(b).health THEN
  1068. '          top(1) = col(b).y
  1069. '          left(1) = col(b).x
  1070. '          bottom(1) = col(b).y + col(b).h
  1071. '          right(1) = col(b).x + col(b).w
  1072.         
  1073. '          IF (left(0) >= right(1)) OR (left(1) > right(0)) OR (top(0) > bottom(1)) OR (top(1) > bottom(0)) THEN
  1074.  
  1075. '          ELSE
  1076. '             grabber(col(b).mem1).mode = 0
  1077. '             col(b).mem1 = 0                    ' clear memory
  1078. '             col(b).mode = 0
  1079. '             col(b).health = 0
  1080. '             pickup = 0                         ' set for another
  1081. '             herolaser(a).health = FALSE
  1082. '             createchunks herolaser(a).x, herolaser(a).y
  1083. '             adlibfx
  1084. '          END IF
  1085.           
  1086.           
  1087. '        END IF
  1088. '       NEXT b
  1089. '     END IF
  1090. '    END IF
  1091. '   END IF
  1092. '   NEXT a
  1093.  
  1094.  
  1095. END SUB
  1096.  
  1097. SUB createalienbolt (x, y)
  1098.     
  1099.   FOR a = 0 TO maxalienbolts
  1100.      IF alienbolt(a).health = 0 AND alienbolt(a).eras = 0 THEN   '  empty spot
  1101.        
  1102.         IF timepassed(2, .6) = 0 THEN EXIT SUB
  1103.         
  1104.         alienbolt(a).x = x + 5
  1105.         alienbolt(a).y = y + 5
  1106.         alienbolt(a).mem1 = x
  1107.         alienbolt(a).mem2 = y
  1108.         alienbolt(a).oldx = alienbolt(a).x
  1109.         alienbolt(a).oldy = alienbolt(a).y
  1110.         alienbolt(a).vx = hero.x
  1111.         alienbolt(a).vy = hero.y
  1112.         alienbolt(a).h = 1
  1113.         alienbolt(a).w = 1
  1114.         alienbolt(a).eras = 0
  1115.         alienbolt(a).health = 20
  1116.         alienbolt(a).thrust = 0
  1117.         EXIT FOR
  1118.      END IF
  1119.   NEXT a
  1120.  
  1121.  
  1122.  
  1123.  
  1124. END SUB
  1125.  
  1126. SUB createalienshot (x, y)
  1127.  
  1128.   '  Finds an empty spot in the alienshot array and initalize it
  1129.   '  with a shot. Figures aim based on location of our hero.
  1130.   
  1131.   '  x = physical x location to shoot from
  1132.   '  y = physical y location to shot from
  1133.     
  1134.    IF alienshot.health = 0 AND alienshot.eras = 0 THEN
  1135.           
  1136.           adlibfx (4)
  1137.         alienshot.health = maxx
  1138.          
  1139.         '  x = x + fnrnd(-5)
  1140.         '  y = y + fnrnd(-5)
  1141.  
  1142.         IF x > hero.x THEN alienshot.dirx = 0
  1143.         IF x < hero.x THEN alienshot.dirx = 1
  1144.         IF y > hero.y THEN alienshot.diry = 0
  1145.         IF y < hero.y THEN alienshot.diry = 1
  1146.  
  1147.  
  1148.         '  IF hero.x < x THEN
  1149.         '    alienshot.dir = 1
  1150.         '  END IF
  1151.  
  1152.         '  IF hero.x > x THEN
  1153.         '     alienshot.dir = 0
  1154.         '  END IF
  1155.  
  1156.           alienshot.vx = 6
  1157.           alienshot.vy = 6
  1158.           alienshot.x = x
  1159.           alienshot.y = y
  1160.           alienshot.oldx = alienshot.x
  1161.           alienshot.oldy = alienshot.y
  1162.           alienshot.mem2 = 0
  1163.           alienshot.h = 2
  1164.           alienshot.w = 2
  1165.           alienshot.eras = 0
  1166.           alienshot.thrust = 0
  1167.          END IF
  1168.  
  1169.        
  1170.  
  1171. END SUB
  1172.  
  1173.  SUB createblocker
  1174.  
  1175.     
  1176.      IF blocker.health = 0 AND blocker.eras = 0 THEN
  1177.          blocker.vy = 1
  1178.          blocker.px = 0
  1179.          blocker.py = 0
  1180.          blocker.dir = fnrnd(2)
  1181.          blocker.h = 10
  1182.          blocker.w = 10
  1183.          blocker.eras = 0
  1184.          blocker.health = 10
  1185.          blocker.mem1 = 0
  1186.          blocker.mem2 = 0
  1187.          blocker.thrust = 0
  1188.          blocker.x = fnrnd(fieldw)
  1189.          blocker.y = 100
  1190.          blocker.cy = 0
  1191.          blocker.oldx = blocker.x
  1192.          blocker.oldy = blocker.y
  1193.    END IF
  1194.  
  1195. END SUB
  1196.  
  1197. SUB createbomb (x, y)
  1198.  
  1199.  
  1200.   IF bomb.health = 0 AND bomb.eras = 0 THEN
  1201.           IF timepassed(10, .5) = 0 THEN EXIT SUB
  1202.           adlibfx (5)
  1203.           bomb.health = (maxy * 5)
  1204.          
  1205.  
  1206.           IF hero.y < y THEN
  1207.             bomb.dir = 1
  1208.             END IF
  1209.  
  1210.           IF hero.y > y THEN
  1211.              bomb.dir = 0
  1212.             END IF
  1213.          
  1214.           IF x > hero.x THEN
  1215.             bomb.vx = 1
  1216.           END IF
  1217.  
  1218.           IF x < hero.x THEN
  1219.             bomb.vx = -1
  1220.           END IF
  1221.  
  1222.  
  1223.           bomb.vy = 8
  1224.           'bomb.cy = 10
  1225.           bomb.x = x
  1226.           bomb.y = y
  1227.           bomb.oldx = bomb.x
  1228.           bomb.oldy = bomb.y
  1229.         
  1230.           bomb.mem2 = 0
  1231.           bomb.h = 2
  1232.           bomb.w = 2
  1233.           bomb.eras = 0
  1234.           bomb.thrust = 0
  1235.          END IF
  1236.  
  1237. END SUB
  1238.  
  1239. SUB createbomer
  1240.  
  1241.   
  1242.   IF bomer(0).played = bomer(0).toplay THEN EXIT SUB
  1243.   IF timepassed(3, .9) = 0 THEN EXIT SUB
  1244.   
  1245.   FOR a = 0 TO maxbomers
  1246.      IF bomer(a).health = 0 AND bomer(a).eras = 0 THEN
  1247.      
  1248.          bomer(a).px = 0
  1249.          bomer(a).py = 0
  1250.          bomer(a).dir = fnrnd(2)
  1251.          bomer(a).h = 6
  1252.          bomer(a).w = 6
  1253.          bomer(a).eras = 0
  1254.          bomer(a).health = 1
  1255.          bomer(a).mem1 = 0
  1256.          bomer(a).mem2 = 0
  1257.          bomer(a).thrust = 0
  1258.          bomer(a).mode = 0
  1259.          bomer(a).x = (fnrnd(fieldw - maxx)) + maxx
  1260.          bomer(a).y = fnrnd(maxy - (25 + 35)) + 35
  1261.          bomer(a).oldx = bomer(a).x
  1262.          bomer(a).oldy = bomer(a).y
  1263.  
  1264.          bomer(0).played = bomer(0).played + 1
  1265.          EXIT SUB
  1266.          END IF
  1267.    NEXT a
  1268.  
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277. END SUB
  1278.  
  1279. SUB createchaser
  1280.  
  1281.   IF timepassed(4, 1) = 0 THEN EXIT SUB
  1282.     IF chaser.toplay = chaser.played THEN EXIT SUB
  1283.  
  1284.      IF (chaser.health = 0 AND chaser.eras = 0) THEN
  1285.          chaser.cx = 0
  1286.          chaser.cy = 0
  1287.          chaser.px = 0
  1288.          chaser.py = 0
  1289.          chaser.h = 3
  1290.          chaser.w = 15
  1291.          chaser.eras = 0
  1292.          chaser.health = 1
  1293.          chaser.mem1 = 0
  1294.          chaser.mem2 = 0
  1295.          chaser.thrust = 0
  1296.          chaser.mode = 0
  1297.          chaser.x = (fnrnd(fieldw - maxx)) + maxx
  1298.          chaser.y = fnrnd(maxy - (25 + 35)) + 35
  1299.          chaser.oldx = chaser.x
  1300.          chaser.oldy = chaser.y
  1301.          chaser.played = chaser.played + 1
  1302.          EXIT SUB
  1303.          END IF
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310. END SUB
  1311.  
  1312.  SUB createchunks (x, y)
  1313.  
  1314.   ' Find an empty spot in the array and initalize it with a chunk
  1315.   ' Chunks fly out when things collide .
  1316.  
  1317.   FOR a = 0 TO maxchunks
  1318.      IF chunk(a).health = 0 AND chunk(a).eras = 0 THEN     ' empty spot
  1319.          chunk(a).x = x
  1320.          chunk(a).y = y
  1321.          chunk(a).oldx = chunk(a).x
  1322.          chunk(a).oldy = chunk(a).y
  1323.          
  1324.          IF fnrnd(2) THEN                   ' randomly select velocitys
  1325.             chunk(a).vx = fnrnd(2) + speed
  1326.          ELSE
  1327.             chunk(a).vx = fnrnd(-2) - speed
  1328.          END IF
  1329.  
  1330.          IF fnrnd(2) THEN
  1331.              chunk(a).vy = fnrnd(2) + speed
  1332.          ELSE
  1333.              chunk(a).vy = fnrnd(-2) - speed
  1334.          END IF
  1335.         
  1336.          chunk(a).h = 1
  1337.          chunk(a).w = 1
  1338.          chunk(a).eras = 0                 ' erase flag
  1339.          chunk(a).health = 50              ' life of a chunk
  1340.          chunk(a).thrust = 0
  1341.          IF ct = 5 THEN EXIT FOR                          ' found one
  1342.          ct = ct + 1
  1343.      END IF
  1344.   NEXT a
  1345.  
  1346.  
  1347.  
  1348.  
  1349. END SUB
  1350.  
  1351. SUB createcolonists
  1352.  
  1353.   FOR a = 0 TO maxcolonists
  1354.      col(a).x = fnrnd(fieldw)
  1355.      col(a).y = (fieldh - 5)
  1356.      col(a).oldx = col(a).x
  1357.      col(a).oldy = col(a).y
  1358.      col(a).vx = 0
  1359.      col(a).vy = 0
  1360.      col(a).dir = 0
  1361.      col(a).h = 5
  1362.      col(a).w = 2
  1363.      col(a).eras = 0
  1364.      col(a).health = 1
  1365.      col(a).mode = 0
  1366.      col(a).mem1 = 0
  1367.      col(a).mem2 = 0
  1368.    NEXT a
  1369.  
  1370. END SUB
  1371.  
  1372. SUB creategrabber
  1373.  
  1374.   ' create grabber
  1375.  
  1376.   
  1377.  
  1378.   IF grabber(0).played = grabber(0).toplay THEN
  1379.     IF timepassed(0, 8) THEN grabber(0).played = grabber(0).played - 1
  1380.     EXIT SUB
  1381.   END IF
  1382.  
  1383.   IF timepassed(1, .9) = 0 THEN EXIT SUB     ' aliens appear about 1 per sec
  1384.  
  1385.   FOR a = 0 TO maxgrabbers
  1386.      IF (grabber(a).health = 0 AND grabber(a).eras = 0 AND grabber(a).mode = 0) THEN
  1387.          grabber(a).cx = 0
  1388.          grabber(a).cy = 0
  1389.          grabber(a).px = 0
  1390.          grabber(a).py = 0
  1391.          grabber(a).dirx = fnrnd(2)
  1392.          grabber(a).h = 8
  1393.          grabber(a).w = 8
  1394.          grabber(a).eras = 0
  1395.          grabber(a).health = 1
  1396.          grabber(a).mem1 = 0           ' used when picking up colonist
  1397.          grabber(a).mem2 = 0           ' used to determine if fired missle
  1398.          grabber(a).thrust = 0
  1399.          grabber(a).mode = 0
  1400.          grabber(a).x = (fnrnd(fieldw - maxx)) + maxx
  1401.          grabber(a).y = fnrnd(maxy - (25 + 35)) + 35
  1402.          grabber(a).oldx = grabber(a).x
  1403.          grabber(a).oldy = grabber(a).y
  1404.          grabber(0).played = grabber(0).played + 1
  1405.          EXIT SUB
  1406.          END IF
  1407.   NEXT a
  1408.  
  1409.  
  1410.  
  1411.  
  1412. END SUB
  1413.  
  1414. DEFSNG A-Z
  1415. SUB createhero
  1416. DEFINT A-Z
  1417.  
  1418.   'hero ship is draw here and its variables initialized.
  1419.   'This will possible be loaded from disk in the future
  1420.   
  1421.     
  1422.   IF hero.x = 0 THEN
  1423.     DIM heroimage(75, 1) AS INTEGER
  1424.     
  1425.     LINE (0, 0)-(25, 15), 0, BF      ' clear the area
  1426.     PSET (0, 0), 0                   ' set graphics cursor
  1427.     LINE -(10, 10), 0                ' move down and over a little
  1428.     LINE -(5, 15), 9                 ' defender facing right
  1429.     LINE -(25, 15), 9
  1430.     LINE -(10, 10), 9
  1431.     PAINT STEP(2, 2), 1, 9
  1432.  
  1433.  
  1434.     LINE (30, 0)-(55, 15), 0, BF      ' clear the area
  1435.     PSET (30, 0), 0                   ' set graphics cursor
  1436.     LINE -(50, 10), 0                 ' move down and over a little
  1437.     LINE -(55, 15), 9                 ' defender facing left
  1438.     LINE -(35, 15), 9
  1439.     LINE (37, 15)-(49, 11), 9
  1440.     PAINT STEP(2, 2), 1, 9
  1441.  
  1442.  
  1443.     GET (5, 10)-(25, 15), heroimage(0, 0)   ' get facing right
  1444.     GET (35, 10)-(55, 15), heroimage(0, 1)  ' get facing left
  1445.  
  1446.     PUT (5, 10), heroimage(0, 0)   ' hide the evidence
  1447.     PUT (35, 10), heroimage(0, 1)
  1448.  
  1449.  END IF
  1450.     
  1451.     hero.x = 130             ' set sprite variables for
  1452.     hero.y = maxy / 2        ' starting location
  1453.     hero.oldx = hero.x       ' so old location can be erased
  1454.     hero.oldy = hero.y
  1455.     hero.vx = 5
  1456.     hero.vy = 2
  1457.     hero.mem2 = hero.vx
  1458.     hero.h = 5               ' highth of image
  1459.     hero.w = 20              ' width of image
  1460.     hero.eras = 0            ' erase flag
  1461.     hero.health = 4          ' sprite active
  1462.     hero.thrust = 0
  1463.     hero.cx = 10
  1464. END SUB
  1465.  
  1466. SUB createherolaser
  1467.  
  1468.   ' find an empty spot in the heromissle array and initalizes with a
  1469.   ' new missle.
  1470.   
  1471.  
  1472.   FOR a = 0 TO maxherolasers
  1473.      IF herolaser(a).health = 0 AND hero.health THEN
  1474.          IF hero.dir THEN                       ' firing left
  1475.            herolaser(a).x = hero.x
  1476.            herolaser(a).y = hero.y + hero.h
  1477.            herolaser(a).dir = 1
  1478.          ELSE                                   ' firing right
  1479.            herolaser(a).x = hero.x + hero.w
  1480.            herolaser(a).y = hero.y + hero.h
  1481.            herolaser(a).dir = 0
  1482.          END IF
  1483.          herolaser(a).oldx = herolaser(a).x
  1484.          herolaser(a).oldy = herolaser(a).y
  1485.          herolaser(a).mem1 = herolaser(a).oldx
  1486.          herolaser(a).mem2 = herolaser(a).oldy
  1487.          herolaser(a).vx = 4 + speed
  1488.          herolaser(a).vy = 0
  1489.          herolaser(a).h = 1
  1490.          herolaser(a).w = 50
  1491.          herolaser(a).eras = 0
  1492.          herolaser(a).health = 1
  1493.          adlibfx (1)
  1494.          EXIT FOR
  1495.      END IF
  1496.   NEXT a
  1497.  
  1498. END SUB
  1499.  
  1500. SUB createmutant (x, y)
  1501.  
  1502.   ' create mutant
  1503.  
  1504.  
  1505.   FOR a = 0 TO maxcolonists
  1506.      IF mutant(a).health = 0 AND mutant(a).eras = 0 THEN
  1507.          mutant(a).px = 0
  1508.          mutant(a).py = 0
  1509.          mutant(a).dir = 0
  1510.          mutant(a).h = 8
  1511.          mutant(a).w = 8
  1512.          mutant(a).eras = 0
  1513.          mutant(a).health = 1
  1514.          mutant(a).mem1 = 0           ' used when picking up colonist
  1515.          mutant(a).mem2 = 0           ' used to determine if fired missle
  1516.          mutant(a).thrust = 0
  1517.          mutant(a).mode = 0
  1518.          mutant(a).x = x
  1519.          mutant(a).y = y
  1520.          mutant(a).oldx = mutant(a).x
  1521.          mutant(a).oldy = mutant(a).y
  1522.          EXIT FOR
  1523.          END IF
  1524.   NEXT a
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533. END SUB
  1534.  
  1535. SUB createspinette (x, y)
  1536.  
  1537.  
  1538.  IF spinette.health = 0 AND spinette.eras = 0 THEN
  1539.    
  1540.     IF timepassed(8, .5) = 0 THEN EXIT SUB
  1541.  
  1542.    IF x > hero.x THEN spinette.dirx = 1
  1543.    IF x < hero.x THEN spinette.dirx = 0
  1544.    IF y > hero.y THEN spinette.diry = 0
  1545.    IF y < hero.y THEN spinette.diry = 1
  1546.  
  1547.   
  1548.    spinette.vx = 5
  1549.    spinette.vy = 5
  1550.    spinette.px = x
  1551.    spinette.py = y
  1552.    spinette.x = x
  1553.    spinette.y = y
  1554.    spinette.oldx = spinette.x
  1555.    spinette.oldy = spinette.y
  1556.    spinette.mem1 = 0
  1557.    spinette.mem2 = 0
  1558.    spinette.h = 2
  1559.    spinette.w = 2
  1560.    spinette.health = 1
  1561.   END IF
  1562.  
  1563.  
  1564.  
  1565.  
  1566. END SUB
  1567.  
  1568. SUB createspinner
  1569.  
  1570.   
  1571.   IF spinner.toplay = spinner.played THEN EXIT SUB
  1572.  
  1573.   IF (spinner.health = 0 AND spinner.eras = 0) THEN
  1574.     IF timepassed(5, 1) = 0 THEN EXIT SUB
  1575.     spinner.cx = 0
  1576.     spinner.cy = 0
  1577.     spinner.px = 0
  1578.     spinner.py = 0
  1579.     spinner.h = 8
  1580.     spinner.w = 8
  1581.     spinner.eras = 0
  1582.     spinner.health = 3
  1583.     spinner.mem1 = -6
  1584.     spinner.mem2 = -1
  1585.     spinner.thrust = 0
  1586.     spinner.mode = 0
  1587.     spinner.x = (fnrnd(fieldw - maxx)) + maxx
  1588.     spinner.y = fnrnd(maxy - topy) + topy
  1589.     spinner.oldx = spinner.x
  1590.     spinner.oldy = spinner.y
  1591.     spinner.played = spinner.played + 1
  1592.   END IF
  1593.  
  1594.    
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602. END SUB
  1603.  
  1604. SUB createtracker
  1605.   
  1606.   IF tracker.toplay = tracker.played THEN EXIT SUB
  1607.  
  1608.   IF (tracker.health = 0 AND tracker.eras = 0) THEN
  1609.     'IF timepassed(5, 1) = 0 THEN EXIT SUB
  1610.     
  1611.     tracker.cx = 0
  1612.     tracker.cy = 0
  1613.     tracker.px = 0
  1614.     tracker.py = 0
  1615.     tracker.h = 8
  1616.     tracker.w = 8
  1617.     tracker.eras = 0
  1618.     tracker.health = 1
  1619.     tracker.mem1 = 150
  1620.     tracker.mem2 = 0
  1621.     tracker.thrust = 0
  1622.     tracker.mode = 0
  1623.     tracker.x = (fnrnd(fieldw - maxx)) + maxx
  1624.     tracker.y = fnrnd(maxy - topy) + topy
  1625.     tracker.oldx = tracker.x
  1626.     tracker.oldy = tracker.y
  1627.     tracker.played = tracker.played + 1
  1628.   END IF
  1629.  
  1630.  
  1631.  
  1632.  
  1633. END SUB
  1634.  
  1635. SUB drawboundrys
  1636.  
  1637.  
  1638. LINE (minx, maxy - 6)-(maxx, maxy - 6), 1
  1639. LINE (minx, miny + 35)-(maxx, miny + 35), 1
  1640.  
  1641.  
  1642. END SUB
  1643.  
  1644. SUB drawplayscreen
  1645.  
  1646.  ' draws stationary elements of the playscreen
  1647.  
  1648.  
  1649.   LINE (radarx - 31, radary)-(radarx + radarw - 28, radary + radarh), 1, B
  1650.   'LINE (radarx - (radarw / 2), radary)-(radarx + radarw - (radarw / 3), radary + radarh), 1, B
  1651.   LINE (radarx, radary + 1)-(radarx + 20, radary + 1), 1
  1652.  
  1653.   LINE (minx, topy - 1)-(maxx, topy - 1), 1
  1654.  
  1655.  
  1656.   p5x7ascfnt 5, 5, "Level", 2
  1657.   p5x7ascfnt 30, 5, STR$(level), 2
  1658.  
  1659. END SUB
  1660.  
  1661. SUB endgame
  1662.      
  1663.  STATIC a, b, c
  1664.  
  1665.  IF hero.health <= 1 THEN
  1666.      IF a = 0 THEN
  1667.        IF timepassed(6, 2) THEN a = 1
  1668.        createchunks hero.x + fnrnd(25), hero.y + fnrnd(10)
  1669.        IF exp1.set = 0 THEN
  1670.          exp1.set = 1
  1671.          exp1.x = hero.x + fnrnd(25)
  1672.          exp1.y = hero.y + fnrnd(25)
  1673.          exp1.size = fnrnd(35)
  1674.          exp1.colour = 14
  1675.        END IF
  1676.      ELSEIF a = 1 THEN
  1677.        exp1.set = 1
  1678.        exp1.x = hero.x + fnrnd(25)
  1679.        exp1.y = hero.y + fnrnd(10)
  1680.        exp1.size = 100
  1681.        exp1.colour = 14
  1682.        hero.health = 0
  1683.        a = 2
  1684.      ELSEIF a = 2 THEN
  1685.  
  1686.      IF timepassed(7, 6) THEN
  1687.        CLS
  1688.        a = 0
  1689.        COLOR 7
  1690.        PRINT "Play again (y,n) ?";
  1691.        
  1692.       IF usepages THEN PCOPY 1, 0
  1693.        DO
  1694.          a$ = INKEY$
  1695.        LOOP WHILE a$ = ""
  1696.        IF a$ = "n" OR a$ = "N" THEN END
  1697.        CLS
  1698.  
  1699.        level = 0
  1700.        hero.health = 4
  1701.       
  1702.      END IF
  1703.    
  1704.     END IF
  1705.  
  1706.  END IF
  1707.  
  1708.  
  1709. END SUB
  1710.  
  1711. FUNCTION joybutt
  1712.  
  1713.   STATIC hold
  1714.   ' returns the current joystick button pressed.
  1715.  
  1716.   joybyte = INP(&H201)
  1717.   joybut1 = 16 AND joybyte
  1718.   joybut2 = 32 AND joybyte
  1719.  
  1720.   IF (NOT (joybut1 AND 16) = 16) THEN joybutt = 1
  1721.   IF (NOT (joybut2 AND 32) = 32) THEN joybutt = 2
  1722.  
  1723.  'DO                                    ' Wait for user to press a button
  1724.  '   joystickbyte = INP(&H201)
  1725.  '  status1 = BUTTA1MASK AND joystickbyte
  1726.  '  status2 = BUTTA2MASK AND joystickbyte
  1727.  ' LOOP WHILE ((status1 AND 16) = 16) AND ((status2 AND 32) = 32)
  1728.   
  1729.  'DO                                        ' Wait for user to let go
  1730.  ' joystickbyte = INP(&H201)
  1731.  ' status1 = BUTTA1MASK AND joystickbyte
  1732.  ' status2 = BUTTA2MASK AND joystickbyte
  1733.  'LOOP WHILE status1 = 0 OR status2 = 0
  1734.  
  1735.  
  1736.   
  1737. END FUNCTION
  1738.  
  1739. FUNCTION joystick
  1740.  
  1741.  
  1742.  ' Routine detects, calibrates, and calculates joystick values.
  1743.  ' which procedures depend on the value of joystat.
  1744.  ' joystat = 1 - joystick detected - calibrate
  1745.  ' joystat = 2 - calibrated
  1746.  ' joystat = 3 - use stick
  1747.  ' joystat = 4 - dont use stick
  1748.  
  1749.  
  1750.  STATIC up, down, left, right, highcount '  referance variables
  1751.  SHARED joystat                '  check this value in other routines
  1752.  
  1753.  
  1754.  ' @ @ detect
  1755.  
  1756.  IF joystat = 0 THEN
  1757.  
  1758.    CONST detectmask = 1     ' joystat bit masks
  1759.    CONST calibmask = 2
  1760.    CONST respondmask = 4
  1761.  
  1762.    CONST XAXISAMASK = 1     ' Mask to isolate bit for x-axis on joysyick A
  1763.    CONST YAXISAMASK = 2     ' Mask to isolate bit for y-axis on joystick A
  1764.    CONST BUTTA1MASK = 16    ' Mask to isolate bit for button 1 on joystick A
  1765.    CONST BUTTA2MASK = 32    ' Mask to isolate bit for button 2 on joystick A
  1766.    CONST ButtB1mask = 64    ' Mask to isolate bit for button 1 on joystick B
  1767.    CONST buttB2mask = 128   ' Mask to isolate bit for button 2 on joystick B
  1768.    CONST Maxintvalue = 32767     ' Maximum value a signed integer can hold
  1769.   
  1770.  
  1771.  
  1772.    sx = 0                                  ' Prepare counter
  1773.    OUT &H201, 0                            ' set joystick bits to 1
  1774.    DO
  1775.      joybyte = INP(&H201)              ' Get joystick byte
  1776.      IF XAXISAMASK AND joybyte THEN    ' Mask unwanted bits
  1777.        sx = sx + 1                          ' Increment counter
  1778.      ELSE
  1779.        EXIT DO                              ' Bit is zero ,stop counting
  1780.      END IF
  1781.    LOOP WHILE sx < Maxintvalue             ' keep counting unless sx= 32767
  1782.  
  1783.    IF sx = Maxintvalue THEN
  1784.      joystat = -1
  1785.      joystick = -99
  1786.      EXIT FUNCTION
  1787.    ELSE
  1788.      joystat = 1
  1789.    END IF
  1790.  
  1791.  END IF
  1792.  
  1793.  ' @ @ calibrate
  1794.  
  1795. '   joyminx = 2: joyminy = 2           ' put this here so I wont have
  1796. '   joycenx = 56: joyceny = 54         ' to calibrate every time
  1797. '   joymaxx = 99: joymaxy = 95
  1798. '    highcount = 100
  1799. '   joystat = 2
  1800.  
  1801.  IF joystat = 1 THEN
  1802.    COLOR 7, 1
  1803.    CLS
  1804.  
  1805.    joyminx = 999      ' initalize minimum values to some big value
  1806.    joyminy = 999      ' that minimum joystick values will never equal
  1807.    boxx = 25
  1808.    boxy = 6
  1809.    curx = 1: oldcurx = 1
  1810.    cury = 1: oldcury = 1
  1811.  
  1812.   ' LOCATE boxy - 3, boxx - 15
  1813.    PRINT
  1814.    PRINT
  1815.    PRINT "                          Circle pad or joystick. "
  1816.    PRINT "              Calibration is complete when values stop changing,   "
  1817.    PRINT " "
  1818.   ' LOCATE boxy + 0, boxx:  PRINT "┌─────────────┬─────────────┐"
  1819.   ' LOCATE boxy + 1, boxx:  PRINT "│             │             │"
  1820.   ' LOCATE boxy + 2, boxx:  PRINT "│             │             │"
  1821.   ' LOCATE boxy + 3, boxx:  PRINT "│             │             │"
  1822.   ' LOCATE boxy + 4, boxx:  PRINT "│          ┌  │  ┐          │"
  1823.   ' LOCATE boxy + 5, boxx:  PRINT "├─────────────┼─────────────┤"
  1824.   ' LOCATE boxy + 6, boxx:  PRINT "│          └  │  ┘          │"
  1825.   ' LOCATE boxy + 7, boxx:  PRINT "│             │             │"
  1826.   ' LOCATE boxy + 8, boxx:  PRINT "│             │             │"
  1827.   ' LOCATE boxy + 9, boxx:  PRINT "│             │             │"
  1828.   ' LOCATE boxy + 10, boxx: PRINT "└─────────────┴─────────────┘"
  1829.    
  1830.     
  1831.    DO
  1832.      
  1833.      'LOCATE oldcury + boxy, oldcurx + boxx: PRINT CHR$(char)
  1834.      'char = SCREEN(cury + boxy, curx + boxx)
  1835.      'LOCATE cury + boxy, curx + boxx: PRINT "█"
  1836.    
  1837.      LOCATE boxy + 2, boxx - 2: PRINT "Minimum x ="; joyminx
  1838.      LOCATE boxy + 3, boxx - 2: PRINT "Maximum x ="; joymaxx
  1839.      LOCATE boxy + 4, boxx - 2: PRINT "Center  x ="; joycenx; "  "
  1840.      'LOCATE boxy + 5, boxx-2: PRINT "Current x ="; joyx; "  "
  1841.  
  1842.      LOCATE boxy + 2, boxx + 17: PRINT "Minimum y ="; joyminy
  1843.      LOCATE boxy + 3, boxx + 17: PRINT "Maximum y ="; joymaxy
  1844.      LOCATE boxy + 4, boxx + 17: PRINT "Center  y ="; joyceny; "  "
  1845.      'LOCATE boxy + 5, boxx + 17: PRINT "Current y ="; joyy; "  "
  1846.  
  1847.      'LOCATE boxy + 16, boxx: PRINT "Highcount"; highcount
  1848.      LOCATE boxy + 8, boxx - 6: PRINT "   Press a joystick button to continue"
  1849.      
  1850.     
  1851.     'for i = 1 to 10000:next           'may need a delay right here
  1852.  
  1853.     joyy = 0: joyx = 0: c = 0: b = 0           ' Prepare counters
  1854.     
  1855.     OUT &H201, 0                           ' set joystick bits to 1
  1856.     DO
  1857.       joybyte = INP(&H201)                 ' Get joystickbyte
  1858.       IF YAXISAMASK AND joybyte THEN       ' Mask unwanted bits
  1859.         joyy = joyy + 1                    ' Increment until bit turns 0
  1860.       ELSE                                 ' do same thing to keep
  1861.         c = c + 1                          ' count accuracy
  1862.       END IF
  1863.       IF XAXISAMASK AND joybyte THEN  ' Mask unwanted bits
  1864.         joyx = joyx + 1                    ' Increment until bit turns 0
  1865.       ELSE                                 ' do same thing to keep
  1866.         c = c + 1                          ' count accuracy
  1867.       END IF
  1868.       b = b + 1
  1869.       IF (XAXISAMASK AND joybyte) = 0 AND (YAXISAMASK AND joybyte) = 0 THEN
  1870.         EXIT DO
  1871.       END IF
  1872.   
  1873.     LOOP
  1874.  
  1875.  
  1876.      IF joyx < joyminx THEN
  1877.        joyminx = joyx
  1878.      END IF
  1879.  
  1880.      IF joyy < joyminy THEN
  1881.        joyminy = joyy
  1882.      END IF
  1883.  
  1884.      IF joyx > joymaxx THEN
  1885.        joymaxx = joyx
  1886.      END IF
  1887.  
  1888.      IF joyy > joymaxy THEN
  1889.        joymaxy = joyy
  1890.      END IF
  1891.   
  1892.      IF b > highcount THEN
  1893.        highcount = b
  1894.      END IF
  1895.  
  1896.  
  1897.      oldcurx = curx
  1898.      oldcury = cury
  1899.   
  1900.      IF joymaxx > 27 THEN               ' scale x cooridinates into box
  1901.        xdivisor = ((joymaxx - joyminx) / 27)
  1902.        IF xdivisor < 1 THEN xdivisor = 1
  1903.        curx = joyx / xdivisor
  1904.        IF curx > 27 THEN curx = 27
  1905.        IF curx < 1 THEN curx = 1
  1906.      END IF
  1907.  
  1908.      IF joymaxy > 9 THEN                ' scale y cooridinates into box
  1909.        ydivisor = ((joymaxy - joyminy) / 9)
  1910.        IF ydivisor < 1 THEN ydivisor = 1
  1911.        cury = joyy / ydivisor
  1912.        IF cury > 9 THEN cury = 9
  1913.        IF cury < 1 THEN cury = 1
  1914.      END IF
  1915.  
  1916.      joycenx = (joymaxx + joyminx) / 2
  1917.      joyceny = (joymaxy + joyminy) / 2
  1918.   
  1919.   
  1920.      joybyte = INP(&H201)
  1921.      joybut1 = BUTTA1MASK AND joybyte
  1922.      joybut2 = BUTTA2MASK AND joybyte
  1923.  
  1924.    LOOP WHILE ((joybut1 AND 16) = 16) AND ((joybut2 AND 32) = 32)
  1925.    joystat = 2
  1926.  
  1927.  END IF
  1928.  
  1929.  
  1930.  ' Now that we have calibration information we can do what we want with it.
  1931.  ' the routines below would change to suit the application.
  1932.  '
  1933.  ' @ @ calculate referance values
  1934.  
  1935.  IF joystat = 2 THEN  'figures 80% of calibrated values in four directions
  1936.    up = joyceny - ((joyceny - joyminy) * .8)
  1937.    down = ((joymaxy - joyceny) * .8) + joyceny
  1938.    left = joycenx - ((joycenx - joyminx) * .8)
  1939.    right = ((joymaxx - joycenx) * .8) + joycenx
  1940.    joystat = 3    ' don't need to do this every time
  1941.  END IF
  1942.  
  1943.  
  1944. ' @ @ calculate return values
  1945. '     I am using return value that equals the direction of the push
  1946. '     relative to degrees. I realize that a portion of the code
  1947. '     is a repeat from above. This is for speed.
  1948.  
  1949.  IF joystat = 3 THEN
  1950.    
  1951.   
  1952.    joyy = 0: joyx = 0: c = 0: b = 0           ' Prepare counters
  1953.    
  1954.    OUT &H201, 0                           ' set joystick bits to 1
  1955.    DO
  1956.      joybyte = INP(&H201)                 ' Get joystickbyte
  1957.      IF YAXISAMASK AND joybyte THEN       ' Mask unwanted bits
  1958.        joyy = joyy + 1                    ' Increment until bit turns 0
  1959.      ELSE                                 ' do same thing to keep
  1960.        c = c + 1                          ' count accuracy
  1961.      END IF
  1962.      IF XAXISAMASK AND joybyte THEN  ' Mask unwanted bits
  1963.        joyx = joyx + 1                    ' Increment until bit turns 0
  1964.      ELSE                                 ' do same thing to keep
  1965.        c = c + 1                          ' count accuracy
  1966.      END IF
  1967.       b = b + 1
  1968.      IF (XAXISAMASK AND joybyte) = 0 AND (YAXISAMASK AND joybyte) = 0 THEN
  1969.       IF b > highcount THEN EXIT DO
  1970.      END IF
  1971.  
  1972.    LOOP
  1973.  
  1974.    'LOCATE 1, 1: PRINT c
  1975.    'DO
  1976.    '  joybyte = INP(&H201)
  1977.    '  c = c + 1
  1978.    'LOOP UNTIL c >= joymax
  1979.  
  1980.  
  1981.    IF joyy <= up THEN                            ' north
  1982.      angle = 1
  1983.    END IF
  1984.   
  1985.    IF joyx >= right THEN                         ' east
  1986.      angle = 90
  1987.    END IF
  1988.   
  1989.    IF joyy >= down THEN                          ' south
  1990.      angle = 180
  1991.    END IF
  1992.   
  1993.    IF joyx <= left THEN                          ' west
  1994.      angle = 270
  1995.    END IF
  1996.                                                
  1997.    IF (joyy <= up) AND (joyx >= right) THEN      ' north east
  1998.      angle = 45
  1999.    END IF
  2000.  
  2001.    IF joyx >= right AND joyy >= down THEN        ' south east
  2002.      angle = 135
  2003.    END IF
  2004.  
  2005.    IF joyx <= left AND joyy >= down THEN         ' southwest
  2006.      angle = 225
  2007.    END IF
  2008.  
  2009.    IF joyy <= left AND joyx <= left THEN         ' northwest
  2010.      angle = 315
  2011.    END IF
  2012.   
  2013.  END IF
  2014.  
  2015.     joystick = angle
  2016.  
  2017. END FUNCTION
  2018.  
  2019. FUNCTION keyboard
  2020.  
  2021.  
  2022.  
  2023.  STATIC chold, althold
  2024.  aski = 0                         ' Reset aski%
  2025.  
  2026.  DEF SEG = &H40                   ' Check state of alt and Ctrl keys
  2027.  IF PEEK(&H17) AND &H4 THEN       ' Mask unwanted bits
  2028.    IF chold = 0 THEN              ' If Ctrl key isn't being held
  2029.      aski = Ctrl                  ' Then process it.
  2030.    END IF
  2031.    chold = 1                      ' Assume the key will be held
  2032.  ELSE
  2033.    chold = 0                      ' Ctrl key was let go
  2034.  END IF
  2035.                                 
  2036. IF PEEK(&H17) AND &H8 THEN        ' Mask unwanted bits
  2037.    IF althold = 0 THEN            ' If alt key isn't being held
  2038.      aski = Alt                   ' Process the key
  2039.    END IF
  2040.    althold = 1                    ' Assume the key will be held
  2041.  ELSE
  2042.    althold = 0                    ' Alt key was let go
  2043.  END IF
  2044.  
  2045.     
  2046.    
  2047.  kee$ = INKEY$                     ' Get a key from the keyboard buffer
  2048.      
  2049.  IF kee$ <> "" THEN                ' If nothing was there why go on ?
  2050.    IF LEN(kee$) = 1 THEN           ' If length = 1 then its a
  2051.      aski = ASC(kee$)              ' regular key code
  2052.    ELSE                            ' Otherwise its an extended
  2053.      aski = -ASC(RIGHT$(kee$, 1))  ' key code
  2054.    END IF
  2055.  END IF
  2056.  
  2057.  
  2058.  keyboard = aski
  2059.  
  2060.  
  2061. END FUNCTION
  2062.  
  2063. SUB killsprites
  2064.  
  2065.   FOR a = 0 TO maxcolonists
  2066.       mutant(a).health = 0
  2067.   NEXT a
  2068.  
  2069.   FOR a = 0 TO maxchunks
  2070.     chunk(a).health = 0
  2071.   NEXT a
  2072.  
  2073.   FOR a = 0 TO maxgrabbers
  2074.     grabber(a).health = 0
  2075.   NEXT a
  2076.   grabber(0).played = 0
  2077.  
  2078.  
  2079.   FOR a = 0 TO maxcolonists
  2080.    mutant(a).health = 0
  2081.   NEXT a
  2082.  
  2083.   FOR a = 0 TO maxbomers
  2084.    bomer(a).health = 0
  2085.   NEXT a
  2086.  
  2087.   blocker.health = 0
  2088.   shot.health = 0
  2089.   bomb.health = 0
  2090.   chaser.health = 0
  2091.  
  2092.   chaser.played = 0
  2093.   bomer(0).played = 0
  2094.   grabber(0).played = 0
  2095.  
  2096.   exp1.set = 0
  2097.  
  2098.  
  2099. END SUB
  2100.  
  2101. SUB levels
  2102.  
  2103.  
  2104.  ' If all aliens have been killed next level is set up.
  2105.  
  2106.  
  2107.  STATIC proceed
  2108.  
  2109.  IF (aliensinplay = 0 AND timepassed(9, 4) = 1) OR level = 0 THEN ' delay a little
  2110.  
  2111.    CLS
  2112.    IF usepages THEN PCOPY 1, 0
  2113.    SLEEP (1)                                   '  delay a little
  2114.    killsprites                                 '  reset sprites
  2115.   
  2116.    SELECT CASE (level)
  2117.  
  2118.    CASE 0
  2119.      maxgrabbers = 3                           '  on playfield at once
  2120.      grabber(0).toplay = 5                     '  amount to play
  2121.      grabber(0).vx = 6: grabber(0).vy = 6      '  velocitys
  2122.  
  2123.      alienshot.vx = 5
  2124.  
  2125.      ' tracker.toplay = 4
  2126.      ' tracker.vx = 6: tracker.vy = 6
  2127.  
  2128.      mutant(0).vx = 6: mutant(0).vy = 6
  2129.     
  2130.      'chaser.toplay = 2
  2131.      'chaser.vx = 4: chaser.vy = 8
  2132.   
  2133.      maxbomers = 0: bomer(0).toplay = 0
  2134.  
  2135.      maxcolonists = 1
  2136.  
  2137.      'spinner.toplay = 1
  2138.      'spinner.vy = 40
  2139.  
  2140.      maxbomers = 1
  2141.      bomer(0).toplay = 3
  2142.      bomer(0).vx = 10: bomer(0).vy = 10
  2143.     
  2144.      'blocker.mode = 1
  2145.      'createblocker
  2146.   
  2147.    CASE 1
  2148.      maxgrabbers = 6                           '  on playfield at once
  2149.      grabber(0).toplay = 8                     '  amount to play
  2150.      grabber(0).vx = 6: grabber(0).vy = 6      '  velocitys
  2151.  
  2152.      alienshot.vx = 5
  2153.  
  2154.      mutant(0).vx = 6: mutant(0).vy = 6
  2155.    
  2156.     ' chaser.toplay = 2
  2157.     ' chaser.vx = 4: chaser.vy = 8
  2158.  
  2159.      maxbomers = 1: bomer(0).toplay = 1
  2160.  
  2161.      maxcolonists = 5
  2162.     
  2163.      maxbomers = 1
  2164.      bomer(0).toplay = 3
  2165.      bomer(0).vx = 10: bomer(0).vy = 10
  2166.    
  2167.      
  2168.    CASE 2
  2169.      maxgrabbers = 6                           '  on playfield at once
  2170.      grabber(0).toplay = 10                     '  amount to play
  2171.      grabber(0).vx = 5: grabber(0).vy = 5      '  velocitys
  2172.  
  2173.      alienshot.vx = 4
  2174.  
  2175.      mutant(0).vx = 5: mutant(0).vy = 5
  2176.     
  2177.      maxcolonists = 5
  2178.     
  2179.      maxbomers = 1
  2180.      bomer(0).toplay = 3
  2181.      bomer(0).vx = 8: bomer(0).vy = 8
  2182.  
  2183.  
  2184.    CASE 3
  2185.  
  2186.      maxgrabbers = 8                           '  on playfield at once
  2187.      grabber(0).toplay = 12                     '  amount to play
  2188.      grabber(0).vx = 5: grabber(0).vy = 5      '  velocitys
  2189.  
  2190.      alienshot.vx = 4
  2191.  
  2192.      ' tracker.toplay = 4
  2193.      ' tracker.vx = 6: tracker.vy = 6
  2194.  
  2195.      mutant(0).vx = 5: mutant(0).vy = 5
  2196.    
  2197.      'chaser.toplay = 2
  2198.      'chaser.vx = 4: chaser.vy = 8
  2199.  
  2200.    
  2201.      'spinner.toplay = 1
  2202.      'spinner.vy = 40
  2203.  
  2204.      maxbomers = 2
  2205.      bomer(0).toplay = 4
  2206.      bomer(0).vx = 8: bomer(0).vy = 8
  2207.    
  2208.      'blocker.mode = 1
  2209.      'createblocker
  2210.  
  2211.     maxcolonists = 6
  2212.   
  2213.  
  2214.    CASE 4
  2215.     
  2216.      maxgrabbers = 8                           '  on playfield at once
  2217.      grabber(0).toplay = 12                     '  amount to play
  2218.      grabber(0).vx = 5: grabber(0).vy = 5      '  velocitys
  2219.  
  2220.      alienshot.vx = 4
  2221.  
  2222.      ' tracker.toplay = 4
  2223.      ' tracker.vx = 6: tracker.vy = 6
  2224.  
  2225.      mutant(0).vx = 4: mutant(0).vy = 4
  2226.   
  2227.      'chaser.toplay = 2
  2228.      'chaser.vx = 4: chaser.vy = 8
  2229.  
  2230.   
  2231.      'spinner.toplay = 1
  2232.      'spinner.vy = 40
  2233.  
  2234.      maxbomers = 2
  2235.      bomer(0).toplay = 5
  2236.      bomer(0).vx = 7: bomer(0).vy = 7
  2237.   
  2238.      'blocker.mode = 1
  2239.      'createblocker
  2240.  
  2241.     maxcolonists = 7
  2242.  
  2243.  
  2244.     
  2245.  
  2246.    CASE 5
  2247.     
  2248.      maxgrabbers = 8                           '  on playfield at once
  2249.      grabber(0).toplay = 16                     '  amount to play
  2250.      grabber(0).vx = 4: grabber(0).vy = 4      '  velocitys
  2251.  
  2252.      alienshot.vx = 3
  2253.  
  2254.      ' tracker.toplay = 4
  2255.      ' tracker.vx = 6: tracker.vy = 6
  2256.  
  2257.      mutant(0).vx = 4: mutant(0).vy = 4
  2258.  
  2259.      'chaser.toplay = 2
  2260.      'chaser.vx = 4: chaser.vy = 8
  2261.  
  2262.  
  2263.      spinner.toplay = 1
  2264.      spinner.vy = 40
  2265.  
  2266.      maxbomers = 2
  2267.      bomer(0).toplay = 5
  2268.      bomer(0).vx = 6: bomer(0).vy = 6
  2269.  
  2270.      maxcolonists = 7
  2271.  
  2272.  
  2273.  
  2274.   CASE 6
  2275.  
  2276.      maxgrabbers = 8                           '  on playfield at once
  2277.      grabber(0).toplay = 18                     '  amount to play
  2278.      grabber(0).vx = 3: grabber(0).vy = 3      '  velocitys
  2279.  
  2280.      alienshot.vx = 3
  2281.  
  2282.      ' tracker.toplay = 4
  2283.      ' tracker.vx = 6: tracker.vy = 6
  2284.  
  2285.      mutant(0).vx = 3: mutant(0).vy = 3
  2286.  
  2287.      chaser.toplay = 2
  2288.      chaser.vx = 4: chaser.vy = 7
  2289.  
  2290.  
  2291.      spinner.toplay = 3
  2292.      spinner.vy = 20
  2293.  
  2294.      maxbomers = 2
  2295.      bomer(0).toplay = 5
  2296.      bomer(0).vx = 5: bomer(0).vy = 5
  2297.  
  2298.      maxcolonists = 7
  2299.   
  2300.     
  2301.    CASE 7
  2302.  
  2303.      maxgrabbers = 8                           '  on playfield at once
  2304.      grabber(0).toplay = 18                     '  amount to play
  2305.      grabber(0).vx = 2: grabber(0).vy = 2      '  velocitys
  2306.  
  2307.      alienshot.vx = 3
  2308.  
  2309.      ' tracker.toplay = 4
  2310.      ' tracker.vx = 6: tracker.vy = 6
  2311.  
  2312.      mutant(0).vx = 3: mutant(0).vy = 3
  2313.  
  2314.      chaser.toplay = 4
  2315.      chaser.vx = 2: chaser.vy = 3
  2316.     
  2317.      spinner.toplay = 3
  2318.      spinner.vy = 4
  2319.  
  2320.      maxbomers = 2
  2321.      bomer(0).toplay = 5
  2322.      bomer(0).vx = 3: bomer(0).vy = 3
  2323.  
  2324.      maxcolonists = 8
  2325.     
  2326.   
  2327.    CASE 8
  2328.  
  2329.      maxgrabbers = 8                           '  on playfield at once
  2330.      grabber(0).toplay = 18                     '  amount to play
  2331.      grabber(0).vx = 2: grabber(0).vy = 2      '  velocitys
  2332.  
  2333.      alienshot.vx = 3
  2334.  
  2335.      ' tracker.toplay = 4
  2336.      ' tracker.vx = 6: tracker.vy = 6
  2337.  
  2338.      mutant(0).vx = 2: mutant(0).vy = 2
  2339.  
  2340.      chaser.toplay = 4
  2341.      chaser.vx = 1: chaser.vy = 3
  2342.    
  2343.      spinner.toplay = 3
  2344.      spinner.vy = 4
  2345.  
  2346.      maxbomers = 2
  2347.      bomer(0).toplay = 5
  2348.      bomer(0).vx = 2: bomer(0).vy = 2
  2349.  
  2350.      maxcolonists = 8
  2351.   
  2352.    CASE 9
  2353.  
  2354.      maxgrabbers = 8                           '  on playfield at once
  2355.      grabber(0).toplay = 18                     '  amount to play
  2356.      grabber(0).vx = 2: grabber(0).vy = 2      '  velocitys
  2357.  
  2358.      alienshot.vx = 3
  2359.  
  2360.      ' tracker.toplay = 4
  2361.      ' tracker.vx = 6: tracker.vy = 6
  2362.  
  2363.      mutant(0).vx = 2: mutant(0).vy = 2
  2364.  
  2365.      chaser.toplay = 4
  2366.      chaser.vx = 2: chaser.vy = 3
  2367.   
  2368.      spinner.toplay = 5
  2369.      spinner.vy = 1
  2370.  
  2371.      maxbomers = 2
  2372.      bomer(0).toplay = 6
  2373.      bomer(0).vx = 1: bomer(0).vy = 1
  2374.  
  2375.      maxcolonists = 8
  2376.  
  2377.  
  2378.    CASE 10
  2379.     
  2380.      maxgrabbers = 8                           '  on playfield at once
  2381.      grabber(0).toplay = 18                     '  amount to play
  2382.      grabber(0).vx = 1: grabber(0).vy = 1      '  velocitys
  2383.  
  2384.      alienshot.vx = 3
  2385.  
  2386.      ' tracker.toplay = 4
  2387.      ' tracker.vx = 6: tracker.vy = 6
  2388.  
  2389.      mutant(0).vx = 2: mutant(0).vy = 2
  2390.  
  2391.      chaser.toplay = 4
  2392.      chaser.vx = 2: chaser.vy = 3
  2393.  
  2394.      spinner.toplay = 5
  2395.      spinner.vy = 1
  2396.  
  2397.      maxbomers = 2
  2398.      bomer(0).toplay = 6
  2399.      bomer(0).vx = 1: bomer(0).vy = 1
  2400.  
  2401.      maxcolonists = 8
  2402.   
  2403.    CASE ELSE
  2404.     CLS
  2405.     SCREEN 0
  2406.     WIDTH 80
  2407.     PRINT " Thats all for now. "
  2408.     PRINT " Hope to here from ya. "
  2409.     PRINT " "
  2410.     PRINT ""
  2411.     PRINT " "
  2412.     END
  2413.  
  2414.    END SELECT
  2415.  
  2416.  
  2417.                                 '  cleanup variables
  2418.    pickup = 0                   '  allow colonist pickups
  2419.    level = level + 1            '  advance level
  2420.   
  2421.    drawplayscreen
  2422.    createcolonists
  2423. END IF
  2424.  
  2425.  
  2426. END SUB
  2427.  
  2428. SUB movesprites
  2429.  
  2430.  
  2431.  
  2432.  STATIC c1
  2433.  
  2434.  aliensinplay = 0                  ' reset grabber body count
  2435.  
  2436.  
  2437.  ' Handle movement of all sprites based on user input or there movement
  2438.  ' algorithms. Sprites are drawn and removed here .Radar positions
  2439.  ' are calculated and placed on screen
  2440.  
  2441.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2442.  '││││││││││││││││││││││││││││││││ grabber ││││││││││││││││││││││││││││││││││
  2443.   
  2444.  
  2445.   FOR a = 0 TO maxgrabbers
  2446.     PSET (grabber(a).oldrx, grabber(a).oldry), 0
  2447.   
  2448.     IF NOT ((grabber(a).x < -10) OR (grabber(a).x > maxx)) THEN  ' Colonist on screen
  2449.      IF grabber(a).eras THEN
  2450.        LINE (grabber(a).oldx, grabber(a).y)-(grabber(a).oldx + grabber(a).w, grabber(a).y + grabber(a).h), 0, BF
  2451.      END IF
  2452.     END IF
  2453.     grabber(a).eras = false
  2454.                                                      ' Shot while desending ?
  2455.     IF grabber(a).health = 0 AND grabber(a).mode = 1 THEN
  2456.        pickup = 0                                     ' reset  pickup
  2457.        grabber(a).mode = 0                            ' reset grabber
  2458.     END IF
  2459.   
  2460.     IF grabber(a).health THEN
  2461.       aliensinplay = aliensinplay + 1
  2462.  
  2463.       traitsgrabber a                      '  personality and movement
  2464.  
  2465.       grabber(a).rx = (grabber(a).x / radarsx) + radarx       ' radar location
  2466.       grabber(a).ry = grabber(a).y / radarsy + radary
  2467.  
  2468.      
  2469.       IF grabber(a).rx > (radarwrapx + radarx) THEN grabber(a).rx = grabber(a).rx - radarw
  2470.     
  2471.       grabber(a).oldrx = grabber(a).rx
  2472.       grabber(a).oldry = grabber(a).ry
  2473.  
  2474.       grabber(a).oldx = grabber(a).x
  2475.       grabber(a).eras = TRUE
  2476.    
  2477.      IF NOT ((grabber(a).x < -10) OR (grabber(a).x > maxx)) THEN ' visable ?
  2478.        LINE (grabber(a).x, grabber(a).y)-(grabber(a).x + grabber(a).w, grabber(a).y + grabber(a).h), 2, BF
  2479.        'p3x5nfnt grabber(a).x, grabber(a).y, a, 2
  2480.        grabber(a).px = POINT(0)
  2481.        grabber(a).py = POINT(1)
  2482.      END IF
  2483.      PSET (grabber(a).rx, grabber(a).ry), 2
  2484.    END IF
  2485.  
  2486.   NEXT
  2487.  
  2488.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2489.  '││││││││││││││││││││││││││││││││ mutant │││││││││││││││││││││││││││││││││││
  2490.  
  2491.   FOR a = 0 TO maxcolonists
  2492.  
  2493.     PSET (mutant(a).oldrx, mutant(a).oldry), 0
  2494.     IF (mutant(a).x > -10) AND (mutant(a).x < maxx) THEN
  2495.      IF mutant(a).eras THEN
  2496.        LINE (mutant(a).oldx, mutant(a).y)-(mutant(a).oldx + mutant(a).w, mutant(a).y + mutant(a).h), 0, BF
  2497.      END IF
  2498.     END IF
  2499.   mutant(a).eras = false
  2500.   
  2501.   IF mutant(a).health THEN
  2502.     aliensinplay = aliensinplay + 1
  2503.  
  2504.     traitsmutant a                      ' personality and movement
  2505.  
  2506.     mutant(a).rx = (mutant(a).x / radarsx) + radarx       ' radar location
  2507.     mutant(a).ry = mutant(a).y / radarsy + radary
  2508.    
  2509.     IF mutant(a).rx > (radarwrapx + radarx) THEN mutant(a).rx = mutant(a).rx - radarw
  2510.     mutant(a).oldrx = mutant(a).rx
  2511.     mutant(a).oldry = mutant(a).ry
  2512.   
  2513.     mutant(a).oldx = mutant(a).x
  2514.     mutant(a).oldy = mutant(a).y
  2515.  
  2516.     IF (mutant(a).x > miny) AND (mutant(a).x < maxx) THEN
  2517.       LINE (mutant(a).x, mutant(a).y)-(mutant(a).x + mutant(a).w, mutant(a).y + mutant(a).h), 4, BF
  2518.       mutant(a).px = POINT(0)
  2519.       mutant(a).py = POINT(1)
  2520.     END IF
  2521.       PSET (mutant(a).rx, mutant(a).ry), 4
  2522.       mutant(a).eras = TRUE
  2523.   END IF
  2524.  
  2525.   NEXT
  2526.  
  2527.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2528.  '││││││││││││││││││││││││││││││││ chaser │││││││││││││││││││││││││││││││││││
  2529.  
  2530.    PSET (chaser.oldrx, chaser.oldry), 0
  2531.     IF (chaser.x > -10) AND (chaser.x < maxx) THEN
  2532.      IF chaser.eras THEN
  2533.        LINE (chaser.oldx, chaser.y)-(chaser.oldx + chaser.w, chaser.y + chaser.h), 0, BF
  2534.      END IF
  2535.     END IF
  2536.    chaser.eras = false
  2537.  
  2538.   IF chaser.health THEN
  2539.     aliensinplay = aliensinplay + 1
  2540.  
  2541.     traitschaser a                      ' personality and movement
  2542.  
  2543.     chaser.rx = (chaser.x / radarsx) + radarx       ' radar location
  2544.     chaser.ry = chaser.y / radarsy + radary
  2545.   
  2546.     IF chaser.rx > (radarwrapx + radarx) THEN chaser.rx = chaser.rx - radarw
  2547.     chaser.oldrx = chaser.rx
  2548.     chaser.oldry = chaser.ry
  2549.  
  2550.     chaser.oldx = chaser.x
  2551.     chaser.oldy = chaser.y
  2552.  
  2553.     IF (chaser.x > miny) AND (chaser.x < maxx) THEN
  2554.       LINE (chaser.x, chaser.y)-(chaser.x + chaser.w, chaser.y + chaser.h), 15, B
  2555.       chaser.px = POINT(0)
  2556.       chaser.py = POINT(1)
  2557.     END IF
  2558.       PSET (chaser.rx, chaser.ry), 15
  2559.       chaser.eras = TRUE
  2560.   END IF
  2561.  
  2562.   
  2563.  
  2564.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2565.  '││││││││││││││││││││││││││││││││ bomer ││││││││││││││││││││││││││││││││││││
  2566.  
  2567.  
  2568.   FOR a = 0 TO maxbomers
  2569.     PSET (bomer(a).oldrx, bomer(a).oldry), 0
  2570.  
  2571.     IF NOT ((bomer(a).x < -10) OR (bomer(a).x > maxx)) THEN
  2572.      IF bomer(a).eras THEN
  2573.        LINE (bomer(a).oldx, bomer(a).y)-(bomer(a).oldx + bomer(a).w, bomer(a).y + bomer(a).h), 0, BF
  2574.        LINE (bomer(a).oldx + bomer(a).w, bomer(a).oldy + bomer(a).h)-(bomer(a).oldx + bomer(a).w + bomer(a).w, bomer(a).oldy + bomer(a).h + bomer(a).h), 0, B
  2575.      END IF
  2576.     END IF
  2577.     bomer(a).eras = false
  2578.  
  2579.     IF bomer(a).health THEN
  2580.      
  2581.       aliensinplay = aliensinplay + 1
  2582.  
  2583.       traitsbomer a                      '  personality and movement
  2584.  
  2585.       bomer(a).rx = (bomer(a).x / radarsx) + radarx       ' radar location
  2586.       bomer(a).ry = bomer(a).y / radarsy + radary
  2587.  
  2588.     
  2589.      IF bomer(a).rx > (radarwrapx + radarx) THEN bomer(a).rx = bomer(a).rx - radarw
  2590.    
  2591.       bomer(a).oldrx = bomer(a).rx
  2592.       bomer(a).oldry = bomer(a).ry
  2593.  
  2594.       bomer(a).oldx = bomer(a).x
  2595.       bomer(a).oldy = bomer(a).y
  2596.  
  2597.       bomer(a).eras = TRUE
  2598.   
  2599.      IF NOT ((bomer(a).x < -10) OR (bomer(a).x > maxx)) THEN ' visable ?
  2600.        LINE (bomer(a).x, bomer(a).y)-(bomer(a).x + bomer(a).w, bomer(a).y + bomer(a).h), 3, B
  2601.        LINE (bomer(a).x + bomer(a).w, bomer(a).y + bomer(a).h)-(bomer(a).x + bomer(a).w + bomer(a).w, bomer(a).y + bomer(a).h + bomer(a).h), 3, B
  2602.  
  2603.        bomer(a).px = POINT(0)
  2604.        bomer(a).py = POINT(1)
  2605.      END IF
  2606.      PSET (bomer(a).rx, bomer(a).ry), 3
  2607.    END IF
  2608.  
  2609.   NEXT
  2610.  
  2611.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2612.  '││││││││││││││││││││││││││││││││ spinner ││││││││││││││││││││││││││││││││││
  2613.  
  2614.   
  2615.     PSET (spinner.oldrx, spinner.oldry), 0
  2616.  
  2617.     IF NOT ((spinner.x < -10) OR (spinner.x > maxx)) THEN
  2618.      IF spinner.eras THEN
  2619.       CIRCLE (spinner.oldx, spinner.oldy), spinner.w, 0, spinner.mem1, spinner.mem2
  2620.       'p5x7ascfnt spinner.oldx, spinner.oldy, "", 0
  2621.      END IF
  2622.     END IF
  2623.     spinner.eras = false
  2624.  
  2625.     IF spinner.health THEN
  2626.     
  2627.       aliensinplay = aliensinplay + 1
  2628.  
  2629.       traitsspinner a                      '  personality and movement
  2630.  
  2631.       spinner.rx = (spinner.x / radarsx) + radarx       ' radar location
  2632.       spinner.ry = spinner.y / radarsy + radary
  2633.  
  2634.    
  2635.      IF spinner.rx > (radarwrapx + radarx) THEN spinner.rx = spinner.rx - radarw
  2636.   
  2637.       spinner.oldrx = spinner.rx
  2638.       spinner.oldry = spinner.ry
  2639.  
  2640.       spinner.oldx = spinner.x
  2641.       spinner.oldy = spinner.y
  2642.  
  2643.       spinner.eras = TRUE
  2644.  
  2645.      IF NOT ((spinner.x < -10) OR (spinner.x > maxx)) THEN ' visable ?
  2646.  
  2647.        c1 = (c1 + 1) MOD 16
  2648.        IF c1 = 15 THEN
  2649.         spinner.mem1 = spinner.mem1 + 1
  2650.         spinner.mem2 = spinner.mem2 + 1
  2651.  
  2652.         IF spinner.mem1 = 0 THEN spinner.mem1 = -6
  2653.         IF spinner.mem2 = 0 THEN spinner.mem2 = -6
  2654.        END IF
  2655.     CIRCLE (spinner.x, spinner.y), spinner.w, 9, spinner.mem1, spinner.mem2
  2656.      '  p5x7ascfnt spinner.x, spinner.y, "", 9
  2657.        spinner.px = POINT(0)
  2658.        spinner.py = POINT(1)
  2659.      END IF
  2660.      PSET (spinner.rx, spinner.ry), 9
  2661.    END IF
  2662.  
  2663.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2664.  '││││││││││││││││││││││││││││││││ spinette │││││││││││││││││││││││││││││││││
  2665.  '                            (spinners weapon)
  2666.    
  2667.     IF NOT ((spinette.x < minx - spinette.w) OR (spinette.x > maxx + spinette.w)) THEN
  2668.      IF spinette.eras THEN
  2669.       CIRCLE (spinette.oldx, spinette.oldy), spinette.w, 0
  2670.       PSET (spinette.x, spinette.y), 0
  2671.      END IF
  2672.     END IF
  2673.     spinette.eras = false
  2674.  
  2675.     IF spinette.health THEN
  2676.       aliensinplay = aliensinplay + 1
  2677.      
  2678.       traitsspinette                       '  movement
  2679.       spinette.eras = TRUE
  2680.  
  2681.       spinette.oldx = spinette.x
  2682.       spinette.oldy = spinette.y
  2683.    IF NOT ((spinette.x < minx - spinette.w) OR (spinette.x > maxx + spinette.w)) THEN
  2684.      CIRCLE (spinette.x, spinette.y), spinette.w, 9
  2685.      PSET (spinette.x, spinette.y), strobe
  2686.    END IF
  2687.        
  2688.    END IF
  2689.     
  2690.   
  2691.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2692.  '││││││││││││││││││││││││││││││││ tracker ││││││││││││││││││││││││││││││││││
  2693.  
  2694.    
  2695.     IF NOT ((tracker.x < -10) OR (tracker.x > maxx)) THEN
  2696.      IF tracker.eras THEN
  2697.        p5x7ascfnt tracker.oldx, tracker.oldy, "", 0
  2698.      END IF
  2699.     END IF
  2700.     tracker.eras = false
  2701.  
  2702.     IF tracker.health THEN
  2703.    
  2704.       aliensinplay = aliensinplay + 1
  2705.  
  2706.       traitstracker a                      '  personality and movement
  2707.      
  2708.      IF tracker.rx > (radarwrapx + radarx) THEN tracker.rx = tracker.rx - radarw
  2709.  
  2710.       tracker.oldx = tracker.x
  2711.       tracker.oldy = tracker.y
  2712.  
  2713.       tracker.eras = TRUE
  2714.  
  2715.      IF NOT ((tracker.x < -10) OR (tracker.x > maxx)) THEN ' visable ?
  2716.        p5x7ascfnt tracker.x, tracker.y, "", 9
  2717.      END IF
  2718.      
  2719.    END IF
  2720.  
  2721.  
  2722.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2723.  '││││││││││││││││││││││││││││││││ blocker ││││││││││││││││││││││││││││││││││
  2724.  
  2725.    
  2726.     PSET (blocker.oldrx, blocker.oldry), 0
  2727.  
  2728.     IF NOT ((blocker.x < -10) OR (blocker.x > maxx)) THEN
  2729.      IF blocker.eras THEN
  2730.        LINE (blocker.oldx, blocker.y)-(blocker.oldx + blocker.w, blocker.y + blocker.h), 0, BF
  2731.      END IF
  2732.     END IF
  2733.     blocker.eras = false
  2734.  
  2735.     IF blocker.health THEN
  2736.      
  2737.       traitsblocker                  '  personality and movement
  2738.  
  2739.       blocker.rx = (blocker.x / radarsx) + radarx       ' radar location
  2740.       blocker.ry = blocker.y / radarsy + radary
  2741.  
  2742.    
  2743.      IF blocker.rx > (radarwrapx + radarx) THEN blocker.rx = blocker.rx - radarw
  2744.   
  2745.       blocker.oldrx = blocker.rx
  2746.       blocker.oldry = blocker.ry
  2747.  
  2748.       blocker.oldx = blocker.x
  2749.       blocker.oldy = blocker.y
  2750.  
  2751.       blocker.eras = TRUE
  2752.  
  2753.      IF NOT ((blocker.x < -10) OR (blocker.x > maxx)) THEN ' visable ?
  2754.      'LINE (blocker(a).x, blocker(a).y)-(blocker(a).x + blocker(a).w, blocker(a).y + blocker(a).h), 3, BF
  2755.      PSET (blocker.x, blocker.y), 3
  2756.      LINE -(blocker.x + blocker.w, blocker.y), 3
  2757.      LINE -(blocker.x + (blocker.w) / 2, blocker.y + blocker.h), 3
  2758.      LINE -(blocker.x, blocker.y), 2
  2759.        'blocker(a).px = POINT(0)
  2760.        'blocker(a).py = POINT(1)
  2761.      END IF
  2762.      PSET (blocker.rx, blocker.ry), 3
  2763.    END IF
  2764.  
  2765.  
  2766.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2767.  '││││││││││││││││││││││││││││││ hero lasers ││││││││││││││││││││││││││││││││
  2768.  
  2769.  FOR a = 0 TO maxherolasers
  2770.  
  2771.    IF herolaser(a).eras THEN                  '  erase old location
  2772.      LINE (herolaser(a).oldx, herolaser(a).oldy)-(herolaser(a).mem1, herolaser(a).mem2), 0
  2773.      herolaser(a).eras = false
  2774.    END IF
  2775.  
  2776.    IF herolaser(a).health THEN
  2777.  
  2778.      herolaser(a).oldx = herolaser(a).x          '  save old location
  2779.      herolaser(a).oldy = herolaser(a).y
  2780.     
  2781.      SELECT CASE herolaser(a).dir
  2782.    
  2783.      CASE 1                                       '  fired left
  2784.  
  2785.        IF herolaser(a).x > minx THEN
  2786.          herolaser(a).x = herolaser(a).x - herolaser(a).vx
  2787.          IF herolaser(a).mem1 > herolaser(a).x + herolaser(a).w THEN
  2788.            herolaser(a).mem1 = herolaser(a).mem1 - herolaser(a).vx
  2789.          END IF
  2790.        ELSE
  2791.          herolaser(a).mem1 = herolaser(a).mem1 - herolaser(a).vx
  2792.        END IF
  2793.     
  2794.       LINE (herolaser(a).x, herolaser(a).y)-(herolaser(a).mem1, herolaser(a).mem2), 7
  2795.         
  2796.        
  2797.       herolaser(a).eras = TRUE                     '  set erase flag
  2798.      
  2799.       IF herolaser(a).mem1 < minx THEN
  2800.          herolaser(a).health = false               ' restore array element
  2801.       END IF
  2802.   
  2803.      CASE 0                                              ' fired right
  2804.       
  2805.        IF herolaser(a).x < maxx THEN
  2806.          herolaser(a).x = herolaser(a).x + herolaser(a).vx
  2807.          IF herolaser(a).mem1 < herolaser(a).x - herolaser(a).w THEN
  2808.            herolaser(a).mem1 = herolaser(a).mem1 + herolaser(a).vx
  2809.          END IF
  2810.        ELSE
  2811.          herolaser(a).mem1 = herolaser(a).mem1 + herolaser(a).vx
  2812.        END IF
  2813.       
  2814.       LINE (herolaser(a).x, herolaser(a).y)-(herolaser(a).mem1, herolaser(a).mem2), 7
  2815.      
  2816.       IF herolaser(a).mem1 > maxx THEN
  2817.          herolaser(a).health = false               ' restore array element
  2818.       END IF
  2819.  
  2820.    END SELECT
  2821.  
  2822.       herolaser(a).eras = TRUE                     '  set erase flag
  2823.  
  2824.   END IF
  2825.  NEXT
  2826.  
  2827.  
  2828.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2829.  '││││││││││││││││││││││││││││││││ chunks │││││││││││││││││││││││││││││││││││
  2830.  
  2831.  FOR a = 0 TO maxchunks
  2832.  
  2833.    IF chunk(a).eras THEN    ' erase old location
  2834.      PSET (chunk(a).oldx, chunk(a).oldy), 0
  2835.      chunk(a).eras = false
  2836.    END IF
  2837.   
  2838.    IF chunk(a).health THEN                            ' dead chunk ?
  2839.       
  2840.       chunk(a).oldx = chunk(a).x                      ' save old location
  2841.       chunk(a).oldy = chunk(a).y
  2842.       aliensinplay = aliensinplay + 1
  2843.       
  2844.       IF chunk(a).y > topy AND chunk(a).y < boty THEN   ' bounds check
  2845.         PSET (chunk(a).x, chunk(a).y), strobe           ' draw chunks
  2846.         chunk(a).thrust = chunk(a).thrust + 1
  2847.         IF chunk(a).thrust = 4 THEN                     '    slow movement
  2848.          chunk(a).x = chunk(a).x + chunk(a).vx
  2849.          chunk(a).y = chunk(a).y + chunk(a).vy           '  move chunk
  2850.          chunk(a).eras = TRUE                            '  erase later
  2851.          chunk(a).health = chunk(a).health - 1          '  shorten life
  2852.          chunk(a).thrust = 0
  2853.        END IF
  2854.  
  2855.       ELSE
  2856.         chunk(a).health = false                  '  open array element
  2857.       END IF
  2858.    END IF
  2859.  NEXT
  2860.  
  2861.  
  2862.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2863.  '││││││││││││││││││││││││││││││ explosion 1 ││││││││││││││││││││││││││││││││
  2864.  
  2865.  
  2866.   IF exp1.set THEN
  2867.      IF exp1.size > exp1.y - topy THEN exp1.size = exp1.y - topy
  2868.        IF exp1.x < maxx THEN
  2869.        exp1.c1 = exp1.c1 + 1
  2870.        IF exp1.c1 < exp1.size THEN
  2871.          CIRCLE (exp1.x, exp1.y), exp1.c1, exp1.colour
  2872.          PAINT (exp1.x, exp1.y), exp1.colour, exp1.colour
  2873.          exp1.c2 = ABS(exp1.c1 - 2)
  2874.          CIRCLE (exp1.x, exp1.y), exp1.c2, 0
  2875.          PAINT (exp1.x, exp1.y), 0, 0
  2876.          
  2877.        ELSEIF exp1.c1 >= exp1.size THEN
  2878.          CIRCLE (exp1.x, exp1.y), exp1.size, 13
  2879.          PAINT (exp1.x, exp1.y), 1, 13
  2880.          CIRCLE (exp1.x, exp1.y), exp1.size, 0
  2881.          PAINT (exp1.x, exp1.y), 0, 0
  2882.          createchunks exp1.x, exp1.y
  2883.          createchunks exp1.x, exp1.y
  2884.           exp1.c1 = 0
  2885.           exp1.set = 0
  2886.          END IF
  2887.     END IF
  2888.   END IF
  2889.  
  2890.  
  2891.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2892.  '││││││││││││││││││││││││││││││││ hero │││││││││││││││││││││││││││││││││││││
  2893.  
  2894.  
  2895.   IF hero.eras THEN
  2896.      LINE (hero.oldx, hero.oldy)-(hero.oldx + hero.w, hero.oldy + hero.h), 0, BF
  2897.      hero.eras = false
  2898.   END IF
  2899.  
  2900.    PSET (hero.oldrx, hero.oldry), 0
  2901.  
  2902.   IF hero.health > 0 THEN
  2903.  
  2904.     hero.oldrx = hero.rx: hero.oldry = hero.ry     ' radar
  2905.     hero.rx = (hero.x / radarsx) + radarx
  2906.     hero.ry = hero.y / radarsy + radary
  2907.     IF hero.rx > (radarwrapx + radarx) THEN col(a).rx = col(a).rx - radarw
  2908.     PSET (hero.rx, hero.ry), 7
  2909.    
  2910.     
  2911.     traitshero                                       'controled user input
  2912.     processgpi
  2913.  
  2914.      IF hero.dir THEN                                 ' facing left
  2915.        IF hero.x <= thrdx THEN                        ' fall back ?
  2916.           hero.x = hero.x + speed                     ' fall to left
  2917.        '   hero.thrust = hero.thrust - speed
  2918.        END IF
  2919.      
  2920.        PUT (hero.x, hero.y), heroimage(0, 1), PSET
  2921.      
  2922.       LINE (hero.x + hero.w - 3, hero.y)-(hero.x + hero.w, hero.y + 3), strobe
  2923.      ELSE                                            ' facing right
  2924.        IF hero.x >= qtrx THEN                       ' fall back ?
  2925.          hero.x = hero.x - speed                         ' fall to left
  2926.        '  hero.thrust = hero.thrust + speed
  2927.        END IF
  2928.          PUT (hero.x, hero.y), heroimage(0, 0), PSET
  2929.        LINE (hero.x + 3, hero.y)-(hero.x, hero.y + 3), strobe
  2930.      END IF
  2931.   END IF
  2932.  
  2933.  
  2934.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2935.  '│││││││││││││││││││││││││││││ alien shots │││││││││││││││││││││││││││││││││
  2936.  
  2937.   
  2938.    IF alienshot.eras THEN                          '  erase old location
  2939.      LINE (alienshot.x, alienshot.y)-(alienshot.x + alienshot.w, alienshot.y + alienshot.h), 0, B
  2940.      alienshot.eras = false
  2941.    END IF
  2942.   
  2943.    IF alienshot.health THEN
  2944.  
  2945.        
  2946.        traitsalienshot
  2947.       
  2948.        alienshot.oldx = alienshot.x          '  save old location
  2949.        alienshot.oldy = alienshot.y
  2950.      
  2951.        LINE (alienshot.x, alienshot.y)-(alienshot.x + alienshot.w, alienshot.y + alienshot.h), 14, B
  2952.        
  2953.        alienshot.eras = TRUE
  2954.    END IF
  2955.    
  2956.   
  2957.  
  2958.  
  2959.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  2960.  '│││││││││││││││││││││││││││││││ alien bombs │││││││││││││││││││││││││││││││
  2961.  
  2962.  
  2963.    IF bomb.eras THEN                          '  erase old location
  2964.      LINE (bomb.x, bomb.y)-(bomb.x + bomb.w, bomb.y + bomb.h), 0, BF
  2965.      bomb.eras = false
  2966.    END IF
  2967.  
  2968.  
  2969.    IF bomb.health THEN
  2970.     
  2971.      IF (bomb.x > minx) AND (bomb.x < maxx) AND (bomb.y > topy) AND (bomb.y < boty) THEN
  2972.  
  2973.        bomb.x = bomb.x - hero.thrust
  2974.        IF bomb.dir = 1 THEN
  2975.          bomb.cy = bomb.cy + 1
  2976.          IF bomb.cy = bomb.vy THEN
  2977.            bomb.y = bomb.y - speed
  2978.            bomb.x = bomb.x - speed - bomb.vx
  2979.            bomb.cy = 0
  2980.          END IF
  2981.        ELSEIF bomb.dir = 0 THEN
  2982.           bomb.cy = bomb.cy + 1
  2983.          IF bomb.cy = bomb.vy THEN
  2984.            bomb.y = bomb.y + speed
  2985.            bomb.x = bomb.x + speed + bomb.vx
  2986.            bomb.cy = 0
  2987.          END IF
  2988.        END IF
  2989.       
  2990.        
  2991.  
  2992.        bomb.oldx = bomb.x          '  save old location
  2993.        bomb.oldy = bomb.y
  2994.        colour = strobe
  2995.        LINE (bomb.x, bomb.y)-(bomb.x + bomb.w, bomb.y + bomb.h), colour, BF
  2996.        bomb.health = bomb.health - 1    ' shorten life
  2997.        bomb.eras = TRUE
  2998.      ELSE
  2999.       bomb.health = 0
  3000.      END IF
  3001.    
  3002.   END IF
  3003.  
  3004.  
  3005.  '│││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││││
  3006.  '││││││││││││││││││││││││││││││││ colonists ││││││││││││││││││││││││││││││││
  3007.  
  3008.   FOR a = 0 TO maxcolonists
  3009.  
  3010.    PSET (col(a).oldrx, col(a).oldry), 0
  3011.  
  3012.    IF NOT ((col(a).x < -10) OR (col(a).x > maxx)) THEN  ' Colonist on screen
  3013.      IF col(a).eras THEN
  3014.        LINE (col(a).oldx, col(a).y)-(col(a).oldx + col(a).w, col(a).y + col(a).h), 0, BF
  3015.      END IF
  3016.    END IF
  3017.  
  3018.    col(a).eras = false
  3019.  
  3020.    IF col(a).health THEN                         ' sprite is alive
  3021.   
  3022.      traitscolonist a
  3023.  
  3024.      col(a).rx = (col(a).x / radarsx) + radarx   '  radar location
  3025.      col(a).ry = col(a).y / radarsy + radary
  3026.        
  3027.      IF col(a).rx > (radarwrapx + radarx) THEN col(a).rx = col(a).rx - radarw
  3028.      col(a).oldrx = col(a).rx                '  save old spot
  3029.      col(a).oldry = col(a).ry
  3030.        
  3031.  
  3032.      col(a).oldx = col(a).x                  '  save old spot
  3033.      col(a).oldy = col(a).y
  3034.  
  3035.      col(a).eras = TRUE                     ' erase it later
  3036.  
  3037.       IF NOT ((col(a).x < -10) OR (col(a).x > maxx)) THEN  ' Colonist on screen
  3038.         LINE (col(a).x, col(a).y)-(col(a).x + col(a).w, col(a).y + col(a).h), 14, BF
  3039.         'col(a).px = POINT(0)
  3040.         'col(a).py = POINT(1)
  3041.         'p3x5numfnt col(a).px - col(a).w, col(a).py - col(a).h, a, 4
  3042.       END IF
  3043.       PSET (col(a).rx, col(a).ry), 14
  3044.  
  3045.     END IF
  3046.   NEXT
  3047.  
  3048.  
  3049. END SUB
  3050.  
  3051. SUB p3x5numfnt (x, y, num, colour)
  3052.  
  3053.   ' Print num at location (x,y) in attribute colour.
  3054.  
  3055.   STATIC a3x5numfnt()
  3056.   
  3057.   IF x = -999 THEN
  3058.     DIM a3x5numfnt(9, 2, 4)
  3059.     DEF SEG = VARSEG(a3x5numfnt(0, 0, 0))         ' load in image file
  3060.     BLOAD "NUM3X5.FNT", 0
  3061.     DEF SEG
  3062.   END IF
  3063.  
  3064.   text$ = LTRIM$(STR$(num))
  3065.   length = LEN(text$) - 1
  3066.  
  3067.    FOR ptr = 0 TO length
  3068.      n = ASC(MID$(text$, ptr + 1, 1)) - 48
  3069.       FOR h = 0 TO 4
  3070.        FOR w = 0 TO 2
  3071.          IF a3x5numfnt(n, w, h) = 1 THEN PSET (w + x + kernx, y + h), colour
  3072.        NEXT w
  3073.      NEXT h
  3074.      kernx = kernx + 4
  3075.    NEXT ptr
  3076.  
  3077. END SUB
  3078.  
  3079. SUB p5x7ascfnt (x, y, text$, colour)
  3080.  
  3081.  ' x and y set screen location to start printing contents of text$.
  3082.  ' Text$ can contain any valid ascii character between 0 and 127.
  3083.  ' colour is the color you would like
  3084.  
  3085.   STATIC a5x7ascfnt()
  3086.  
  3087.   IF x = -999 THEN
  3088.     DIM a5x7ascfnt(127, 4, 6)
  3089.     DEF SEG = VARSEG(a5x7ascfnt(0, 0, 0))         ' load in image file
  3090.     BLOAD "ASCII5X7.FNT", 0
  3091.     DEF SEG
  3092.   END IF
  3093.  
  3094.  
  3095.   l = LEN(text$)                 ' How many times to loop?
  3096.   IF l = 0 THEN EXIT SUB         ' Nothing to do.
  3097.  
  3098.   FOR ptr = 0 TO l - 1       ' -1 is for Mid$ unability to deal with a zero
  3099.  
  3100.    piece$ = MID$(text$, ptr + 1, 1)   ' look at each piece of string
  3101.  
  3102.    n = ASC(piece$)                     ' assign it's ascii value
  3103.  
  3104.   SELECT CASE (piece$)      ' adjust lower case letter down where nessesary
  3105.                             ' looks nice
  3106.    CASE "g"
  3107.      kerny = kerny + 2
  3108.    CASE "j"
  3109.      kerny = kerny + 2
  3110.    CASE "p"
  3111.      kerny = kerny + 2
  3112.    CASE "q"
  3113.      kerny = kerny + 2
  3114.    CASE "y"
  3115.      kerny = kerny + 2
  3116.    END SELECT
  3117.  
  3118.                                 ' write the character
  3119.   FOR h = 0 TO 6
  3120.    FOR w = 0 TO 4
  3121.      IF a5x7ascfnt(n, w, h) = 1 THEN
  3122.        PSET (x + w + kernx, y + h + kerny), colour
  3123.      END IF
  3124.    NEXT
  3125.   NEXT
  3126.  
  3127.   SELECT CASE (piece$)         ' Kern adjusment
  3128.                                ' adjust x value for even spacing
  3129.    CASE "i"
  3130.      kernx = kernx + 2
  3131.    CASE "j"
  3132.      kernx = kernx + 5
  3133.    CASE "l"
  3134.      kernx = kernx + 2
  3135.    CASE "r"
  3136.      kernx = kernx + 5
  3137.    CASE "."
  3138.      kernx = kernx + 3
  3139.    CASE "("
  3140.      kernx = kernx + 3
  3141.    CASE ")"
  3142.      kernx = kernx + 3
  3143.    CASE "'"
  3144.      kernx = kernx + 2
  3145.    CASE "!"
  3146.     kernx = kernx + 2
  3147.    CASE ELSE
  3148.      kernx = kernx + 6
  3149.   END SELECT
  3150.  
  3151.    kerny = 0
  3152.  
  3153. NEXT
  3154.  
  3155.  
  3156. END SUB
  3157.  
  3158.  SUB printins
  3159.  
  3160.  CLS
  3161.  PRINT " To Play : "
  3162.  PRINT " "
  3163.  PRINT " Use the joystick to move the ship around and press either"
  3164.  PRINT " joystick button to fire. But a gamepad will provide better "
  3165.  PRINT " respose."
  3166.  PRINT " Fire at everything. If a green alien grabs a colonist"
  3167.  PRINT " at the bottom shoot him before he reaches the top of the screen."
  3168.  PRINT " If you fail to do this the colonist will be converted to a"
  3169.  PRINT " mutant who will try to attack you. If you shoot the green alien"
  3170.  PRINT " before he reaches the top with the colonist, the colonist will fall."
  3171.  PRINT " Try to catch him with your ship and bring him to the bottom before"
  3172.  PRINT " he lets go from exhaustion and drops to his death."
  3173.  PRINT ""
  3174.  COLOR 14
  3175.  PRINT " During the game press :"
  3176.  PRINT " +    to speed up game"
  3177.  PRINT " -    to slow it down "
  3178.  PRINT " esc  to end the game"
  3179.  PRINT : PRINT
  3180.  PRINT "Press any key to continue."
  3181.  
  3182.  
  3183. DO: LOOP WHILE INKEY$ = ""
  3184. END SUB
  3185.  
  3186. SUB printme
  3187. CLS
  3188. PRINT " Thanks for downloading the program. "
  3189. PRINT " "
  3190. PRINT " I was messing around with the old Atari 2600 and though I would"
  3191. PRINT " give defender a try. This is just a test to see what it would "
  3192. PRINT " involve and may not work correctly on all systems. Speaking of "
  3193. PRINT " which the program is far form perfect. The control is a little"
  3194. PRINT " difficult and there are a few occasions when it acts wierdly."
  3195. PRINT " But I thougt it was interesting so I fiqured I'd see what everybody"
  3196. PRINT " else thinks."
  3197. PRINT " "
  3198. PRINT " Questions, Comments or Critisims :"
  3199. PRINT " AOL -Tim Truman"
  3200. PRINT " Compuserve - 74734,2203"
  3201. PRINT " "
  3202. COLOR 14
  3203. 'PRINT "Use pages (y,n)?"; : COLOR 7: PRINT "     Select y if your pc is very fast"
  3204. 'DO
  3205. '  a$ = INKEY$
  3206. 'LOOP UNTIL LCASE$(a$) = "y" OR LCASE$(a$) = "n"
  3207. 'IF LCASE$(a$) = "y" THEN
  3208. '  Pageswap = TRUE
  3209. 'ELSE
  3210.   Pageswap = false
  3211. 'END IF
  3212. COLOR 7
  3213. PRINT
  3214. PRINT "Press any key. "
  3215.  
  3216. DO: LOOP WHILE INKEY$ = ""
  3217.  
  3218.  
  3219. END SUB
  3220.  
  3221. SUB processgpi
  3222.  
  3223.  
  3224.  aski = keyboard
  3225.  
  3226.  
  3227.  SELECT CASE (aski)
  3228.  
  3229.  CASE 8                                  ' Backspace key
  3230.            
  3231.  CASE 9                                  ' Tab key
  3232.            
  3233.  CASE 13                                 ' Return
  3234.            
  3235.  CASE 27                                 ' Escape key
  3236.    END
  3237.  CASE 32, 53                             ' Space bar ,Five Key
  3238.    createherolaser
  3239.  CASE 43, 61                                ' + , =
  3240.    delay = delay - 100
  3241.    IF delay < 0 THEN
  3242.      delay = 0
  3243.      speed = speed + 1
  3244.      IF speed > 6 THEN speed = 6
  3245.    END IF
  3246.  
  3247.  CASE 45, 95                                ' - , _
  3248.    speed = speed - 1
  3249.    IF speed < 1 THEN speed = 1
  3250.    delay = delay + 100
  3251.    
  3252.  'CASE 22 TO 127                          ' Letter keys
  3253.            
  3254.  CASE -59                                ' Function key 1
  3255.    level = level + 1
  3256.  CASE -60                                ' Function key 2
  3257.            
  3258.  CASE -61                                ' Function key 3
  3259.            
  3260.  CASE -62                                ' Function key 4
  3261.            
  3262.  CASE -63                                ' Function key 5
  3263.            
  3264.  CASE -64                                ' Function key 6
  3265.  
  3266.  CASE -65                                ' Function key 7
  3267.            
  3268.  CASE -66                                ' Function key 8
  3269.            
  3270.  CASE -67                                ' Function key 9
  3271.            
  3272.  CASE -68                                ' Function key 10
  3273.            
  3274.  CASE -133                               ' Function key 11
  3275.            
  3276.  CASE -134                               ' Function key 12
  3277.            
  3278.  CASE -71                                ' Home
  3279.  
  3280.  CASE -72, 56                            ' Up key ,Eight key
  3281.   
  3282.     'hero.cy = hero.cy + 1
  3283.     'IF hero.cy >= hero.vy THEN
  3284.       hero.y = hero.y - speed - keyspeed
  3285.       'hero.cy = 0
  3286.     'END IF
  3287.  
  3288.  CASE -75, 52                             ' Left key
  3289.     hero.thrust = -speed - keyspeed
  3290.     hero.dir = 1
  3291.  
  3292.  CASE -77, 54                               ' Right key
  3293.     hero.thrust = speed + keyspeed
  3294.     hero.dir = 0
  3295.  
  3296.  CASE -79                                ' End key
  3297.  
  3298.  CASE -80, 50                               ' Down key
  3299.     'hero.y = hero.y + hero.vy
  3300.     'hero.cy = hero.cy + 1
  3301.     'IF hero.cy >= hero.vy THEN
  3302.       hero.y = hero.y + speed + keyspeed
  3303.       hero.cy = 0
  3304.     'END IF
  3305.   
  3306.  CASE -82                                ' Insert key
  3307.  
  3308.  CASE -83                                ' Delete key
  3309.  
  3310.  CASE Ctrl
  3311.  
  3312.  CASE Alt
  3313.  
  3314.  CASE ELSE                               ' do nothing
  3315.                  
  3316.  END SELECT
  3317.  
  3318.  IF hero.y < topy THEN hero.y = topy
  3319.  IF hero.y > maxy - col(0).h - hero.h - 2 THEN hero.y = maxy - col(0).h - hero.h - 2
  3320.  
  3321.  
  3322.  IF hero.x < 0 THEN hero.x = minx
  3323.  IF hero.x > (maxx - hero.vx - hero.w) THEN hero.x = maxx - hero.w - 1
  3324.  
  3325.  
  3326. END SUB
  3327.  
  3328. SUB setfxmode
  3329.  
  3330.   ' setscreen and scales relavent varables
  3331.  
  3332.  
  3333.   
  3334.   IF Pageswap THEN
  3335.      SCREEN 7, , 1, 0
  3336.   ELSE
  3337.     SCREEN 13
  3338.   END IF
  3339.  
  3340.  
  3341.   minx = 0               ' actual physical coordinates of screen mode
  3342.   miny = 0
  3343.  
  3344.  'maxx = 649
  3345.  'maxy = 199
  3346.  
  3347.   maxx = 319
  3348.   maxy = 199
  3349.  
  3350.  
  3351.  qtrx = maxx / 4
  3352.  thrdx = qtrx * 3
  3353.  
  3354.  topy = miny + (maxy / 7)' + 28       ' top and bottom physical boundrys
  3355.  boty = maxy - 5
  3356.  
  3357.  fieldw = maxx * 4      ' virtual play field
  3358.  fieldh = maxy
  3359.  
  3360.  radarsx = 16                 ' radar scale down
  3361.  radarsy = 8
  3362.  
  3363.  radarw = fieldw / radarsx    ' physical radar size
  3364.  radarh = fieldh / radarsy
  3365.  
  3366.  radarx = (maxx / 2) - 10        ' physical radar location
  3367.  radary = 1
  3368.  
  3369.  radarwrapx = (radarw / 2) + (radarw / 9)  ' for radar wrap
  3370.  radar2thrd = radar1thrd * 2
  3371.  
  3372.  
  3373. END SUB
  3374.  
  3375. SUB starfield
  3376.  
  3377.  SHARED maxx, maxy
  3378.  STATIC first, oldstarx() AS INTEGER, oldstary() AS INTEGER
  3379.  STATIC starx() AS INTEGER, stary() AS INTEGER, starspeed() AS INTEGER
  3380.  STATIC starvx() AS INTEGER, ns
  3381.  
  3382.   IF ns = 0 THEN                     ' First time here initialize values
  3383.     ns = 25                          ' Number of stars
  3384.     DIM oldstarx(ns)   AS INTEGER
  3385.     DIM oldstary(ns)   AS INTEGER
  3386.     DIM starx(ns)      AS INTEGER
  3387.     DIM stary(ns)      AS INTEGER
  3388.     DIM starspeed(ns)  AS INTEGER
  3389.     DIM starvx(ns)    AS INTEGER
  3390.     FOR c = 0 TO ns
  3391.         stary(c) = fnrnd(maxy - (25 + 35)) + 35
  3392.         starx(c) = fnrnd(maxx)
  3393.         starspeed(c) = 1'fnrnd(2) + 1
  3394.      NEXT
  3395.  END IF
  3396.  
  3397.  
  3398.  
  3399.   FOR c = 0 TO ns                                 '    erase old points
  3400.      PSET (starx(c), stary(c)), 0
  3401.   NEXT
  3402.  
  3403.   ' ** use a delay here if you dont use page switching  **
  3404.   'FOR x! = 0 TO 1000: NEXT
  3405.  
  3406.  'IF hero.thrust THEN LOCATE 1, 1: PRINT hero.dir; hero.thrust
  3407.   IF (hero.dir = 1) AND hero.thrust THEN
  3408.     FOR c = 0 TO ns
  3409.  
  3410.       oldstary(c) = stary(c)           '   save position to erase oldstar
  3411.       oldstarx(c) = starx(c)
  3412.     
  3413.       IF oldstary(c) = 0 THEN
  3414.         stary(c) = fnrnd(maxy - (topy + 35)) + 35
  3415.         starspeed(c) = 1'fnrnd(2) + 1
  3416.         oldstary(c) = stary(c)
  3417.       END IF
  3418.    
  3419.     'starvx(c) = ((starvx(c) + 1) MOD 4)
  3420.     'IF starvx(c) = 3 THEN starx(c) = starx(c) + starspeed(c)
  3421.  
  3422.       starx(c) = starx(c) - hero.thrust
  3423.  
  3424.     IF starx(c) > maxx THEN
  3425.       stary(c) = 0
  3426.       starx(c) = 0
  3427.     END IF
  3428.    NEXT
  3429.   END IF
  3430.  
  3431.    IF hero.dir = 0 AND hero.thrust THEN
  3432.  
  3433.     FOR c = 0 TO ns
  3434.  
  3435.       oldstary(c) = stary(c)           '   save position to erase oldstar
  3436.       oldstarx(c) = starx(c)
  3437.     
  3438.       IF oldstary(c) = maxy THEN
  3439.         stary(c) = fnrnd(maxy - (topy + 35)) + 35
  3440.         starspeed(c) = 1'fnrnd(2) + 1
  3441.         oldstary(c) = stary(c)
  3442.       END IF
  3443.     
  3444.          
  3445.       'starvx(c) = ((starvx(c) + 1) MOD 4)
  3446.       'IF starvx(c) = 3 THEN starx(c) = starx(c) - starspeed(c)
  3447.    
  3448.       starx(c) = starx(c) - hero.thrust
  3449.       IF starx(c) < 1 THEN
  3450.         stary(c) = maxy
  3451.         starx(c) = maxx
  3452.       END IF
  3453.  
  3454.    NEXT
  3455.    END IF
  3456.  
  3457.    FOR c = 0 TO ns
  3458.       PSET (starx(c), stary(c)), 7
  3459.    NEXT
  3460.  
  3461.  
  3462.  
  3463.  
  3464.  
  3465.  
  3466. END SUB
  3467.  
  3468. FUNCTION strobe
  3469.  
  3470.   ' returns next color
  3471.   STATIC colour
  3472.   colour = (colour + 1) MOD 16
  3473.   strobe = colour
  3474.  
  3475.  
  3476. END FUNCTION
  3477.  
  3478. FUNCTION timepassed (n, tsecs!)
  3479.  
  3480.   STATIC getclock(), oldtsecs!(), time1!()
  3481.  
  3482.   IF tsecs! = 0 THEN
  3483.     DIM getclock(n)
  3484.     DIM oldtsecs!(n)
  3485.     DIM time1!(n)
  3486.   END IF
  3487.  
  3488.  
  3489.  IF tsecs! <> oldtsecs!(n) THEN getclock(n) = 0
  3490.  
  3491.  IF getclock(n) = 0 THEN
  3492.    time1!(n) = TIMER
  3493.    getclock(n) = 1
  3494.    oldtsecs!(n) = tsecs!
  3495.  ELSE
  3496.    IF ABS(TIMER - time1!(n)) >= tsecs! THEN
  3497.        timepassed = 1
  3498.        getclock(n) = 0
  3499.    ELSE
  3500.        timepassed = 0
  3501.    END IF
  3502.  END IF
  3503.  
  3504.  
  3505. END FUNCTION
  3506.  
  3507. SUB traitsalienshot
  3508.  
  3509. '     IF (alienshot.x > minx) AND (alienshot.x < maxx) AND (alienshot.y > topy) AND (alienshot.y < boty) THEN
  3510. '       alienshot.x = alienshot.x - hero.thrust
  3511. '       IF alienshot.dir = 1 THEN
  3512. '         alienshot.cx = alienshot.cx + 1
  3513. '         IF alienshot.cx = alienshot.vx THEN
  3514. '           alienshot.x = alienshot.x - speed
  3515. '           alienshot.cx = 0
  3516. '         END IF
  3517.      
  3518. '       ELSEIF alienshot.dir = 0 THEN
  3519. '         alienshot.cx = alienshot.cx + 1
  3520. '         IF alienshot.cx = alienshot.vx THEN
  3521. '           alienshot.x = alienshot.x + speed
  3522. '           alienshot.cx = 0
  3523. '         END IF
  3524. '
  3525. '       END IF
  3526.      
  3527. '       alienshot.y = alienshot.y + alienshot.vy
  3528.  
  3529.  
  3530.   IF hero.thrust THEN alienshot.x = alienshot.x - hero.thrust
  3531.  
  3532.    IF alienshot.dirx = 0 THEN
  3533.       alienshot.cx = alienshot.cx + 1
  3534.       IF alienshot.cx > alienshot.vx THEN
  3535.         alienshot.x = alienshot.x - speed
  3536.         alienshot.cx = 0
  3537.       END IF
  3538.    END IF
  3539.  
  3540.    IF alienshot.dirx = 1 THEN
  3541.       alienshot.cx = alienshot.cx + 1
  3542.       IF alienshot.cx > alienshot.vx THEN
  3543.         alienshot.x = alienshot.x + speed
  3544.         alienshot.cx = 0
  3545.        
  3546.       END IF
  3547.    END IF
  3548.  
  3549.    IF alienshot.diry = 0 THEN
  3550.       alienshot.cy = alienshot.cy + 1
  3551.       IF alienshot.cy > alienshot.vy THEN
  3552.         alienshot.y = alienshot.y - speed
  3553.         alienshot.cy = 0
  3554.       END IF
  3555.    END IF
  3556.  
  3557.    IF alienshot.diry = 1 THEN
  3558.       alienshot.cy = alienshot.cy + 1
  3559.       IF alienshot.cy > alienshot.vy THEN
  3560.         alienshot.y = alienshot.y + speed
  3561.         alienshot.cy = 0
  3562.       END IF
  3563.    END IF
  3564.  
  3565.  
  3566.  
  3567.   IF alienshot.x > maxx OR alienshot.x < minx THEN alienshot.health = 0
  3568.  
  3569.   IF alienshot.x > fieldw THEN alienshot.x = 0        ' bounds check
  3570.   IF alienshot.x < 0 THEN alienshot.x = fieldw
  3571.  
  3572.   IF alienshot.y < topy + alienshot.h THEN
  3573.     alienshot.health = 0
  3574.     'PRINT "ahloha"
  3575.   END IF
  3576.  
  3577.   IF alienshot.y > boty - alienshot.h THEN
  3578.     alienshot.health = 0
  3579.     
  3580.   END IF
  3581.  
  3582. END SUB
  3583.  
  3584. SUB traitsblocker
  3585.  
  3586.  
  3587.   IF hero.thrust THEN blocker.x = blocker.x - hero.thrust
  3588.  
  3589.      blocker.cy = blocker.cy + 1
  3590.      IF blocker.cy = blocker.vy THEN
  3591.        IF blocker.dir THEN
  3592.          blocker.y = blocker.y + speed
  3593.        ELSE
  3594.          blocker.y = blocker.y - speed
  3595.       END IF
  3596.       blocker.cy = 0
  3597.      END IF
  3598.  
  3599.  
  3600.   IF blocker.x > fieldw THEN blocker.x = 0        ' bounds check
  3601.   IF blocker.x < 0 THEN blocker.x = fieldw
  3602.  
  3603.  
  3604.   IF blocker.y > boty - blocker.h THEN     ' bounds check
  3605.   '  IF blocker.mode = 0 THEN
  3606.   '    blocker.y = topy
  3607.   '  ELSEIF blocker.mode = 1 THEN
  3608.       blocker.dir = 0
  3609.   '  END IF
  3610.   END IF
  3611.  
  3612.   IF blocker.y < topy + blocker.vy THEN
  3613.   '  IF blocker.mode = 0 THEN
  3614.   '    blocker.y = boty - blocker.h
  3615.   '  ELSEIF blocker.mode = 1 THEN
  3616.       blocker.dir = 1
  3617.   '  END IF
  3618.   END IF
  3619.  
  3620.  
  3621.  
  3622.  
  3623. END SUB
  3624.  
  3625. SUB traitsbomer (a)
  3626.  
  3627.    IF hero.thrust THEN bomer(a).x = bomer(a).x - hero.thrust
  3628.  
  3629.    IF (bomer(a).x > minx) AND (bomer(a).x < maxx - bomer(a).w) THEN '  Shoot at hero.
  3630.       createbomb bomer(a).px, bomer(a).py
  3631.    END IF
  3632.  
  3633.  
  3634.      bomer(a).cx = bomer(a).cx + 1
  3635.      IF bomer(0).vx < bomer(a).cx THEN
  3636.        IF bomer(a).dir THEN
  3637.          bomer(a).x = bomer(a).x + speed
  3638.         ELSE
  3639.          bomer(a).x = bomer(a).x - speed
  3640.        END IF
  3641.        bomer(a).cx = 0
  3642.      END IF
  3643.    
  3644.      bomer(a).cy = bomer(a).cy + 1
  3645.      IF bomer(0).vy < bomer(a).cy THEN
  3646.        IF bomer(a).dir THEN
  3647.          bomer(a).y = bomer(a).y + speed
  3648.        ELSE
  3649.          bomer(a).y = bomer(a).y - speed
  3650.       END IF
  3651.       bomer(a).cy = 0
  3652.      END IF
  3653.  
  3654.   IF bomer(a).x > fieldw THEN bomer(a).x = 0        ' bounds check
  3655.   IF bomer(a).x < 0 THEN bomer(a).x = fieldw
  3656.  
  3657.   IF bomer(a).y > boty - bomer(a).h THEN bomer(a).y = topy + bomer(a).h  ' bounds check
  3658.   IF bomer(a).y < topy + bomer(a).h THEN bomer(a).y = boty - bomer(a).h
  3659.  
  3660.  
  3661. END SUB
  3662.  
  3663. SUB traitschaser (a)
  3664.  
  3665.     IF hero.thrust THEN chaser.x = chaser.x - hero.thrust
  3666.  
  3667.     
  3668.     ' match hero.y when on screen
  3669.     IF chaser.x > minx AND chaser.x < maxx THEN
  3670.  
  3671.        IF chaser.y < hero.y THEN
  3672.         chaser.cy = chaser.cy + 1
  3673.         IF chaser.vy = chaser.cy THEN
  3674.           chaser.y = chaser.y + speed
  3675.           chaser.cy = 0
  3676.         END IF
  3677.        END IF
  3678.  
  3679.        IF chaser.y > hero.y THEN
  3680.         chaser.cy = chaser.cy + 1
  3681.         IF chaser.vy = chaser.cy THEN
  3682.           chaser.y = chaser.y - speed
  3683.           chaser.cy = 0
  3684.         END IF
  3685.        END IF
  3686.   
  3687.       chaser.mem1 = 1
  3688.     END IF
  3689.  
  3690.     ' find hero.x after being found
  3691.  
  3692.     IF chaser.mem1 = 1 THEN
  3693.  
  3694.     IF chaser.x < minx OR chaser.px > maxx THEN speedier = 1 ELSE speedier = 0
  3695.  
  3696.  
  3697.      chaser.cx = chaser.cx + 1
  3698.       
  3699.      IF chaser.x > hero.x THEN
  3700.       IF chaser.vx <= chaser.cx THEN
  3701.          chaser.x = chaser.x - speed - speedier
  3702.          chaser.cx = 0
  3703.       END IF
  3704.      ELSEIF chaser.x < hero.x THEN
  3705.       IF chaser.vx <= chaser.cx THEN
  3706.          chaser.x = chaser.x + speed + speedier
  3707.          chaser.cx = 0
  3708.       END IF
  3709.      END IF
  3710.    
  3711.    
  3712.    END IF
  3713.  
  3714.   IF chaser.x > fieldw THEN chaser.x = 0        ' bounds check
  3715.   IF chaser.x < 0 THEN chaser.x = fieldw
  3716.  
  3717.   IF chaser.y < topy THEN chaser.y = topy
  3718.   IF chaser.y > boty - chaser.h THEN chaser.y = boty - chaser.h
  3719.  
  3720.  
  3721.  
  3722. END SUB
  3723.  
  3724. SUB traitscolonist (a)
  3725.  
  3726.      'IF hero.thrust THEN                         ' move according to hero
  3727.        col(a).x = col(a).x - hero.thrust
  3728.        IF col(a).x > fieldw THEN col(a).x = 0
  3729.        IF col(a).x < 0 THEN col(a).x = fieldw
  3730.        col(a).eras = TRUE
  3731.      'END IF
  3732.  
  3733.  
  3734.     IF col(a).mode = 1 THEN                      '  grabber has colonist
  3735.        IF (grabber(col(a).mem1).health > 0) THEN
  3736.           col(a).cx = col(a).cx + 1
  3737.           IF col(a).cx >= grabber(0).vy THEN
  3738.             col(a).y = col(a).y - speed
  3739.             col(a).cx = 0
  3740.           END IF
  3741.           col(a).mem2 = col(a).y                 ' in case grabber gets shot
  3742.        ELSE                                      ' grabber was shot
  3743.          col(a).cx = ((col(a).cx + 1) MOD 8)
  3744.          IF col(a).vy >= col(a).cx THEN          ' slow down the drop
  3745.            col(a).y = col(a).y + speed
  3746.            IF col(a).y > maxy - 6 THEN
  3747.              grabber(col(a).mem1).mode = 0       ' reset variables
  3748.              col(a).mem1 = 0
  3749.              col(a).mode = 0
  3750.              col(a).dir = 0
  3751.              pickup = 0
  3752.              b = timepassed(11, 1)               ' reset timer 11
  3753.              IF col(a).mem2 < maxy - 75 THEN
  3754.                createchunks col(a).x, col(a).y - 10
  3755.                col(a).health = 0
  3756.              END IF
  3757.            END IF
  3758.          END IF
  3759.        END IF
  3760.  
  3761.    ELSEIF col(a).mode = 2 THEN             ' hero got em
  3762.  
  3763.      col(a).x = hero.x: col(a).y = hero.y
  3764.      col(a).dir = 1
  3765.      col(a).mem2 = col(a).y
  3766.      IF timepassed(11, 3) THEN col(a).mode = 1
  3767.      IF hero.y > boty - 10 THEN col(a).mode = 1
  3768.  
  3769.    END IF
  3770.  
  3771.  
  3772.  
  3773.  
  3774.  
  3775. END SUB
  3776.  
  3777. SUB traitsgrabber (a)
  3778.  
  3779.   '  Grabber personality defined here.
  3780.    
  3781.    SHARED pickup
  3782.    STATIC ctr1, ctr2, ctr3
  3783.   'IF hero.thrust THEN
  3784.    grabber(a).x = grabber(a).x - hero.thrust
  3785.  
  3786.    IF (grabber(a).x > minx) AND (grabber(a).x < maxx) THEN   '  Shoot at hero.
  3787.       createalienshot grabber(a).px, grabber(a).py
  3788.    END IF
  3789.  
  3790.  
  3791.   SELECT CASE grabber(a).mode
  3792.  
  3793.   CASE 0                                         ' looking for colonist
  3794.     
  3795.      grabber(a).cx = grabber(a).cx + 1
  3796.      IF grabber(0).vx <= grabber(a).cx THEN
  3797.       IF grabber(a).dirx = 0 THEN
  3798.         grabber(a).x = grabber(a).x + speed
  3799.       ELSEIF grabber(a).dirx = 1 THEN
  3800.         grabber(a).x = grabber(a).x - speed
  3801.       END IF
  3802.       'ctr1 = ctr1 + 1
  3803.      grabber(a).cx = 0
  3804.     END IF
  3805.  
  3806.     IF level < 5 THEN
  3807.      
  3808.       IF ctr1 > 200 THEN grabber(a).diry = 1
  3809.       IF ctr1 > 310 THEN grabber(a).diry = 3
  3810.       IF ctr1 > 400 THEN grabber(a).diry = 0
  3811.       IF ctr1 > 490 THEN ctr1 = 0
  3812.  
  3813.  
  3814.        IF ctr1 > 200 AND ctr1 < 490 THEN
  3815.         grabber(a).cy = grabber(a).cy + 1
  3816.         IF grabber(0).vy = grabber(a).cy THEN
  3817.           IF grabber(a).diry = 0 THEN
  3818.             grabber(a).y = grabber(a).y + speed
  3819.           ELSEIF grabber(a).diry = 1 THEN
  3820.             grabber(a).y = grabber(a).y - speed
  3821.           END IF
  3822.          grabber(a).cy = 0
  3823.         END IF
  3824.       END IF
  3825.     ELSE
  3826.    
  3827.  
  3828.     END IF
  3829.    
  3830.     IF pickup = 0 THEN
  3831.      ' COLOR strobe
  3832.      ' LOCATE 1, 1: PRINT "looking"
  3833.       FOR b = 0 TO maxcolonists         '  pick up when visible 
  3834.        ' IF (col(b).x > 0) AND (col(b).x < maxx) AND col(b).health THEN
  3835.           IF col(b).health THEN
  3836.             IF grabber(a).x = col(b).x THEN         ' got that sucker
  3837.               IF fnrnd(2) = 0 THEN                  ' pick at random
  3838.                grabber(a).mode = 1                   ' pick up  mode
  3839.                grabber(a).mem1 = b                   ' remember the colonist
  3840.                col(b).mem1 = a                       ' remember the grabber
  3841.                pickup = 1
  3842.               END IF
  3843.             END IF
  3844.           END IF
  3845.        ' END IF
  3846.      NEXT
  3847.     END IF
  3848.    
  3849.   
  3850.   CASE 1                                         '  desend over victom  ;)
  3851.     'COLOR strobe
  3852.     'LOCATE 1, 10: PRINT "desending"
  3853.     grabber(a).cy = grabber(a).cy + 1
  3854.    
  3855.     IF grabber(a).cy = grabber(0).vy THEN
  3856.       grabber(a).y = grabber(a).y + speed
  3857.       grabber(a).cy = 0
  3858.     END IF
  3859.  
  3860.     IF grabber(a).y > maxy - grabber(a).h - 5 THEN
  3861.       grabber(a).y = maxy - grabber(a).h - 5
  3862.       grabber(a).mode = 2
  3863.       adlibfx (2)
  3864.     END IF
  3865.  
  3866.   CASE 2                                          ' pick up victom
  3867.  
  3868.     'COLOR strobe
  3869.     'LOCATE 1, 20: PRINT "Picking up"
  3870.  
  3871.     grabber(a).cy = grabber(a).cy + 1
  3872.     IF grabber(a).cy = grabber(0).vy THEN
  3873.       grabber(a).y = grabber(a).y - speed
  3874.       col(grabber(a).mem1).mode = 1
  3875.       grabber(a).cy = 0
  3876.     END IF
  3877.      
  3878.     IF grabber(a).y < topy THEN     ' did grabber reach top ?
  3879.       grabber(a).y = topy
  3880.       grabber(a).mode = 3
  3881.     END IF
  3882.                                       ' convert to mental grabber
  3883.     CASE 3
  3884.        'COLOR strobe
  3885.        'LOCATE 1, 31: PRINT "Mental  "
  3886.        col(grabber(a).mem1).health = 0
  3887.        col(grabber(a).mem1).mode = 0
  3888.        grabber(a).mode = 0
  3889.        grabber(a).mem1 = 0
  3890.        grabber(a).health = 0
  3891.        pickup = 0
  3892.        adlibfx (3)
  3893.        createmutant grabber(a).x, grabber(a).y
  3894.    
  3895.   END SELECT
  3896.  
  3897.  
  3898.   IF grabber(a).y > boty - grabber(a).h THEN grabber(a).y = topy ' bounds check
  3899.   IF grabber(a).y < topy THEN grabber(a).y = boty - grabber(a).h
  3900.  
  3901.     
  3902.   IF grabber(a).x > fieldw THEN grabber(a).x = 0        ' bounds check
  3903.   IF grabber(a).x < 0 THEN grabber(a).x = fieldw
  3904.  
  3905.  
  3906. END SUB
  3907.  
  3908. SUB traitshero
  3909.  
  3910.  ' hero controled by user input
  3911.  
  3912.  hero.oldy = hero.y
  3913.  hero.oldx = hero.x
  3914.  hero.eras = TRUE
  3915.  
  3916.  degrees = joystick
  3917.  
  3918.  hero.thrust = false
  3919.  
  3920.  'IF hero.x <= thrdx THEN                        ' fall back ?
  3921.  '  hero.x = hero.x + speed                      ' fall to left
  3922.  '  'hero.thrust = hero.thrust - speed
  3923.  '  degrees = 270
  3924.  'END IF
  3925.  'IF hero.x >= qtrx THEN                       ' fall back ?
  3926.  '   hero.x = hero.x - speed                         ' fall to left
  3927.  '  hero.thrust = hero.thrust + speed
  3928.  ' degrees = 90
  3929.  'END IF
  3930.  
  3931.  
  3932.  SELECT CASE (degrees)
  3933.  CASE 1                                   '  north
  3934.     hero.cy = hero.cy + 1
  3935.     IF hero.cy >= hero.vy THEN
  3936.       hero.y = hero.y - speed
  3937.       hero.cy = 0
  3938.     END IF
  3939.  CASE 45                                  '  north east
  3940.     'hero.y = hero.y - hero.vy
  3941.     hero.cy = hero.cy + 1
  3942.     IF hero.cy >= hero.vy THEN
  3943.       hero.y = hero.y - speed
  3944.       hero.cy = 0
  3945.     END IF
  3946.  
  3947.     hero.thrust = speed
  3948.     hero.dir = 0
  3949.  CASE 90                                  '  east
  3950.     hero.thrust = speed
  3951.     hero.dir = 0
  3952.  CASE 135                                 '  south east
  3953.     
  3954.     hero.cy = hero.cy + 1
  3955.     IF hero.cy >= hero.vy THEN
  3956.       hero.y = hero.y + speed
  3957.       hero.cy = 0
  3958.     END IF
  3959.  
  3960.     hero.thrust = speed
  3961.     hero.dir = 0
  3962.  CASE 180                                 '  south
  3963.     'hero.y = hero.y + hero.vy
  3964.     hero.cy = hero.cy + 1
  3965.     IF hero.cy >= hero.vy THEN
  3966.       hero.y = hero.y + speed
  3967.       hero.cy = 0
  3968.     END IF
  3969.  
  3970.  CASE 225                                 '  south west
  3971.     
  3972.     hero.cy = hero.cy + 1
  3973.     IF hero.cy >= hero.vy THEN
  3974.       hero.y = hero.y + speed
  3975.       hero.cy = 0
  3976.     END IF
  3977.  
  3978.     hero.thrust = -speed
  3979.     hero.dir = 1
  3980.  CASE 270                                    '  west
  3981.       hero.thrust = -speed
  3982.       hero.dir = 1
  3983.  CASE 315                                 '  north west
  3984.     'hero.y = hero.y - hero.vy
  3985.     hero.cy = hero.cy + 1
  3986.     IF hero.cy >= hero.vy THEN
  3987.       hero.y = hero.y - speed
  3988.       hero.cy = 0
  3989.     END IF
  3990.  
  3991.     hero.thrust = -speed
  3992.     hero.dir = 1
  3993.  END SELECT
  3994.  
  3995.  
  3996.  ' joystick buttons
  3997.  
  3998.  SELECT CASE (joybutt)
  3999.  
  4000.  CASE (1)
  4001.    createherolaser
  4002.  CASE (2)
  4003.    createherolaser
  4004.  END SELECT
  4005.  
  4006.  
  4007.  
  4008.  IF hero.y < topy THEN hero.y = topy
  4009.  IF hero.y > maxy - col(0).h - hero.h - 2 THEN hero.y = maxy - col(0).h - hero.h - 2
  4010.   
  4011.  
  4012.  IF hero.x < 0 THEN hero.x = minx
  4013.  IF hero.x > (maxx - hero.vx - hero.w) THEN hero.x = maxx - hero.w - 1
  4014.  
  4015.  
  4016.  
  4017.  
  4018.  
  4019. END SUB
  4020.  
  4021. SUB traitsmutant (a)
  4022.  
  4023.   ' mutant is aggresive and pissed off
  4024.  
  4025.   IF hero.thrust THEN mutant(a).x = mutant(a).x - hero.thrust
  4026.  
  4027.   'IF mutant(a).x > minx AND mutant(a).x < maxx THEN   ' mutant on screen
  4028.    
  4029.      'createalienbolt mutant(a).x, mutant(a).y
  4030.  
  4031.      mutant(a).cx = (mutant(a).cx + 1) MOD (mutant(0).vx + 1)
  4032.      IF mutant(0).vx = mutant(a).cx THEN
  4033.       IF mutant(a).px > hero.x THEN mutant(a).x = mutant(a).x - fnrnd(speed + 1)
  4034.       IF mutant(a).px < hero.x THEN mutant(a).x = mutant(a).x + fnrnd(speed + 1)
  4035.      END IF
  4036.     
  4037.      mutant(a).cy = (mutant(a).cy + 1) MOD (mutant(0).vy + 1)
  4038.      IF mutant(0).vy = mutant(a).cy THEN
  4039.       IF mutant(a).y > hero.y THEN mutant(a).y = mutant(a).y - fnrnd(speed + 1)
  4040.       IF mutant(a).y < hero.y THEN mutant(a).y = mutant(a).y + fnrnd(speed + 1)
  4041.      END IF
  4042.  
  4043.  
  4044.      IF fnrnd(2) THEN
  4045.        mutant(a).y = mutant(a).y + fnrnd(speed + 1)
  4046.       ELSE
  4047.        mutant(a).y = mutant(a).y - fnrnd(speed + 1)
  4048.      END IF
  4049.  
  4050.      IF fnrnd(2) THEN
  4051.        mutant(a).x = mutant(a).x + fnrnd(speed + 1)
  4052.       ELSE
  4053.        mutant(a).x = mutant(a).x - fnrnd(speed + 1)
  4054.      END IF
  4055.  
  4056.  
  4057.   IF mutant(a).x > fieldw THEN mutant(a).x = 0        ' bounds check
  4058.   IF mutant(a).x < 0 THEN mutant(a).x = fieldw
  4059.  
  4060.   IF mutant(a).y < topy THEN mutant(a).y = topy
  4061.   IF mutant(a).y > boty - mutant(a).h THEN mutant(a).y = boty - mutant(a).h
  4062.  
  4063.  
  4064.  
  4065. END SUB
  4066.  
  4067. SUB traitsspinette
  4068.  
  4069.   
  4070.   IF hero.thrust THEN spinette.x = spinette.x - hero.thrust
  4071.  
  4072.    IF spinette.dirx = 0 THEN
  4073.       spinette.cx = spinette.cx + 1
  4074.       IF spinette.cx > spinette.vx THEN
  4075.         spinette.x = spinette.x - speed
  4076.         spinette.cx = 0
  4077.       END IF
  4078.    END IF
  4079.  
  4080.    IF spinette.dirx = 1 THEN
  4081.       spinette.cx = spinette.cx + 1
  4082.       IF spinette.cx > spinette.vx THEN
  4083.         spinette.x = spinette.x + speed
  4084.         spinette.cx = 0
  4085.         
  4086.       END IF
  4087.    END IF
  4088.  
  4089.    IF spinette.diry = 0 THEN
  4090.       spinette.cy = spinette.cy + 1
  4091.       IF spinette.cy > spinette.vy THEN
  4092.         spinette.y = spinette.y - speed
  4093.         spinette.cy = 0
  4094.       END IF
  4095.    END IF
  4096.  
  4097.    IF spinette.diry = 1 THEN
  4098.       spinette.cy = spinette.cy + 1
  4099.       IF spinette.cy > spinette.vy THEN
  4100.         spinette.y = spinette.y + speed
  4101.         spinette.cy = 0
  4102.       END IF
  4103.    END IF
  4104.  
  4105.   
  4106.  
  4107.   IF spinette.x > maxx OR spinette.x < minx THEN spinette.health = 0
  4108.  
  4109.   IF spinette.x > fieldw THEN spinette.x = 0        ' bounds check
  4110.   IF spinette.x < 0 THEN spinette.x = fieldw
  4111.  
  4112.   IF spinette.y < topy + spinette.h + spinette.h THEN spinette.health = 0'spinette.y = boty - spinette.h
  4113.   IF spinette.y > boty - spinette.h THEN spinette.health = 0 'spinette.y = topy + spinette.h
  4114.  
  4115.  
  4116.  
  4117. END SUB
  4118.  
  4119. SUB traitsspinner (a)
  4120.  
  4121.   STATIC c1
  4122.  
  4123.   IF hero.thrust THEN spinner.x = spinner.x - hero.thrust
  4124.  
  4125.    IF (spinner.x > minx) AND (spinner.x < maxx) THEN    '  Shoot at hero.
  4126.       createspinette spinner.x, spinner.y
  4127.    END IF
  4128.  
  4129.  
  4130.  
  4131.    spinner.cy = spinner.cy + 1
  4132.  
  4133.    IF spinner.dir = 0 THEN
  4134.       IF spinner.cy >= spinner.vy THEN
  4135.         spinner.y = spinner.y + speed
  4136.         spinner.cy = 0
  4137.         c1 = (c1 + 1) MOD 20: IF c1 = 0 THEN spinner.dir = 1
  4138.       END IF
  4139.    ELSEIF spinner.dir = 1 THEN
  4140.       IF spinner.cy >= spinner.vy THEN
  4141.         spinner.y = spinner.y - speed
  4142.         spinner.cy = 0
  4143.         c1 = (c1 + 1) MOD 20: IF c1 = 0 THEN spinner.dir = 0
  4144.       END IF
  4145.    END IF
  4146.  
  4147.   IF spinner.x > fieldw THEN spinner.x = 0        ' bounds check
  4148.   IF spinner.x < 0 THEN spinner.x = fieldw
  4149.  
  4150.   IF spinner.y < topy + spinner.h THEN spinner.y = boty - spinner.h
  4151.   IF spinner.y > boty - spinner.h THEN spinner.y = topy + spinner.h
  4152.  
  4153.  
  4154. END SUB
  4155.  
  4156. SUB traitstracker (a)
  4157.  
  4158.    LOCATE 1, 1: PRINT tracker.x
  4159.  
  4160.    IF hero.thrust THEN tracker.x = tracker.x - hero.thrust
  4161.  
  4162.    IF (tracker.x > minx) AND (tracker.x < maxx) THEN    '  Shoot at hero.
  4163.        'createalienshot tracker.x, tracker.y
  4164.   
  4165.    END IF
  4166.   
  4167.  
  4168.    IF tracker.x > hero.x + (tracker.mem1) THEN
  4169.  
  4170.      'tracker.x = tracker.x + 1
  4171.  
  4172.    END IF
  4173.  
  4174.  
  4175.    IF tracker.x < hero.x - (tracker.mem1) THEN
  4176.  
  4177.      'tracker.x = tracker.x - 1
  4178.  
  4179.    END IF
  4180.  
  4181.  
  4182.  
  4183.  
  4184.   IF tracker.x > fieldw THEN tracker.x = 0             ' bounds check
  4185.   IF tracker.x < 0 THEN tracker.x = fieldw
  4186.  
  4187.   IF tracker.y < topy + tracker.h THEN tracker.y = boty - tracker.h
  4188.   IF tracker.y > boty - tracker.h THEN tracker.y = topy + tracker.h
  4189.  
  4190.  
  4191. END SUB
  4192.  
  4193. SUB WriteReg (reg, value)
  4194.  
  4195. ' Writes to AdLib's registers the delays required when writing to these
  4196. ' ports are present.
  4197. '
  4198. ' Reg is the register to write to. Value is the data to send.
  4199.  
  4200.  
  4201. OUT &H388, reg     '  388h = Register/Status port
  4202.                    '  Tells the SB what register we want to write to
  4203.  
  4204.                    '  Calling the register port 6 times creates an
  4205.                    '  accurate delay of 3.3ms. This delay is required
  4206. FOR x = 0 TO 5     '  after writing to the register port.
  4207.    a = INP(&H388)
  4208. NEXT x
  4209.  
  4210. OUT &H389, value   '  389h = data port
  4211.                    '  send data that corrisponds with the requested register.
  4212.  
  4213.                    '  Calling the data port 35 times creates an
  4214.                    '  accurate delay of 23ms. This delay is required.
  4215. FOR x = 0 TO 34    '  after writing to the data port.
  4216.    a = INP(&H388)
  4217. NEXT x
  4218.  
  4219.  
  4220. END SUB
  4221.  
  4222.